Calculate number of day of year

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Calculate number of day of year

Post by Silvio.Falconi »

my problem is to calculate the progressive number of a day
1 1 2020 ---> corresponds to the first day of the year
2 2 2020 ---> corresponds to 33rd day of the year

How I can calculate the number of day of year ?

sample

0059 is 29.02.2020

if (month == 1)
nprog = g; // in the case of January
else
nprog = (30 * (month-1)) + day; // I put it on the 30th, taking it for granted that every month they have 30 days

But I'm not sure that's the case ... help me
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculate number of day of year

Post by Silvio.Falconi »

I made another test

Function test()
Local ddata
Local nreturn

SET DATE ITALIAN
ddata:=date()

nReturn := dData- CTOD("01/01/"+RIGHT(DTOC(dData),2)) +1

RETURN nReturn

return 36577 ( today 21.02.2020)

why not run ok
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Calculate number of day of year

Post by nageswaragunupudi »

Code: Select all

? DOY( dDate )
 
Example:
Today is 20th Feb 2020.

Code: Select all

? DOY( Date() ) // --> 52
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
armando.lagunas
Posts: 340
Joined: Mon Oct 05, 2009 3:35 pm
Location: Curico-Chile
Contact:

Re: Calculate number of day of year

Post by armando.lagunas »

funciones de fecha en xHarbour

Code: Select all

AddMonth() Adds or subtracts a number of months to/from a Date value.
BoM() Returns the date of the first day of a month.
BoQ() Returns the date of the first day of a quarter.
BoY() Returns the date of the first day of a year.
CDoW() Returns the name of a week day from a date.
CMonth() Returns the name of a month from a date.
CtoD() Converts a character string into a Date value
CtoDoW() Returns the number of a week day from its name.
CtoMonth() Returns the number of a month from its name.
CtoT() Converts a character string into a DateTime value
Date() Returns the current date from the operating system.
DateTime() Returns the current date and time from the operating system.
Day() Extracts the numeric day number from a Date value.
Days() Calculates the number of days from elapsed seconds.
DaysInMonth() Returns the number of days in a month.
DaysToMonth() Returns the number of days from first January to the beginning of a month.
DMY() Formats a date as "dd. Month yyyy"
DoW() Determines the numeric day of the week from a date.
DoY() Returns the day number of a Date value in a year.
DtoC() Converts a Date value to a character string in SET DATE format.
DtoS() Converts a Date value to a character string in YYYYMMDD format.
ElapTime() Calculates the time elapsed between a start and an end time.
EoM() Returns the date of the last day in a month.
EoQ() Returns the date of the last day in a quarter.
EoY() Returns the date for the last day of a year.
HB_Clocks2Secs() Calculates seconds from CPU ticks.
Hour() Extracts the hour from a DateTime value
IsLeap() Checks if a Date value belongs to a leap year.
LastDayoM() Returns the number of days in a month.
Max() Returns the larger value of two Numerics or Dates.
MDY() Formats a date as "Month dd, yy".
MilliSec() Defines a time delay in milliseconds.
Min() Returns the smallerr value of two Numerics or Dates.
Minute() Extracts the minute from a DateTime value
Month() Extracts the numeric month number from a Date value.
NtoCDoW() Converts a numeric week day to its name.
NtoCMonth() Converts a numeric month to its name.
Quarter() Returns the quarter a date belongs to.
Seconds() Returns the number of seconds elapsed since midnight
SecondsCpu() Returns the CPU time used by the current process.
Secs() Calculates the number of seconds from a time string.
SecToTime() Converts numeric seconds into a time formatted character string.
SetDate() Changes the system date from a Date value.
SetNewDate() Changes the system date from Numeric values.
SetNewTime() Changes the system time from Numeric values.
SetTime() Changes the system time from a Time string.
ShowTime() Displays the system time continuously at a specified screen position.
StoD() Converts a "yyyymmdd" formatted string to a Date value
StoT() Converts a "YYYYMMDDhhmmss.ccc" formatted string to a DateTime value
SX_DtoP() Converts a Date value into a 3-byte character string.
SX_PtoD() Unpacks a packed 3-byte date value.
Time() Retrieves the system time as a formatted character string.
TimeToSec() Calculates the number of seconds since midnight.
TimeValid() Checks if a character string is a valid time string.
TString() Converts numeric seconds into a time formatted character string.
TtoC() Converts a DateTime value to a character string in SET DATE and SET TIME format.
TtoS() Converts a Date value to a character string in YYYYMMDDhhmmss.ccc format.
WaitPeriod() Defines a wait period and allows for time controlled loops.
Week() Calculates the numeric calendar week from a date.
WoM() Calculates the week number in a month.
Year() Extracts the numeric year from a Date value 

 
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculate number of day of year

Post by Silvio.Falconi »

Sorry Nages,

I didn't even think there was a function,
I trusted the old source in ca-clipper which had the s_doyear function that I couldn't find in fwh,
it was probably a function of the ct or superlib library.
Thank you all
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply