Get day of year

delphi

    Next

  • 1. userenv.h? wtsapi32.h?
    Hi all, I find myself in need of some functions in the windows userenv API. I can't find a userenv.pas as a standard part of my delphi 6 enterprise. Can anyone tell me if there is one readily available, or give me hints as to how I would go about writing one based on userenv.h if needed? I also have the same question about wtsapi32. thanks, Dave
  • 2. Windows Shutdown in code
    Roy wrote: > Hi, > Does anyone have some reliable code for shutting windows (2000) down > from within a Delphi (6) program? > > In the past I've used the freeware abf components but this no longer seems > to work. This is almost certainly due to the fact that your program needs the correct privileges to shut down the system under Windows 2000. Specifically, you need to call AdjustTokenPrivileges with the SE_SHUTDOWN_NAME flag. Seach Google groups for "Delphi ExitWindowsEx 2000" or similar, this has been answered many times before. -- jc Remove the -not from email
  • 3. IP Popup Ads
    Does anyone know how to turn off IP Popup Ads from Windows without using a program? It seems to me I saw something in an article on how to do this. Gary
  • 4. Bitmaps default to cyan, not black?
    Hi, a strange thing has happened lately. If I create a bitmap the background defaults to cyan and not black. This didn't used to happen, has anyone else experienced this?

Get day of year

Postby pjwolters » Fri, 03 Jun 2005 03:33:22 GMT

Does anyone know how to get the day of the year for a date like
21/06/2005 ??
I did found some info, but it isn't working..

thnx,

Peter


Re: Get day of year

Postby Dodgy » Fri, 03 Jun 2005 03:55:32 GMT

On 1 Jun 2005 11:33:22 -0700, "pjwolters" < XXXX@XXXXX.COM >
waffled on about something:


May I recommend efg's Delphi reference library.

 http://www.**--****.com/ 

I'm not sure if you're after the day of the week, sun-sat, or if you
want to know how many days into the year you are.

If it's day of the week, you just need to work from a known point and
then do a mod7 of the result.

e.g. use Monday, like Jan. 1, 1900 as the known base

DaysSince1900 :=
     TRUNC(EncodeDate(year,month,day)) -
     TRUNC(EncodeDate(1900,1,1)) + 1;
DayOfWeek := DaysSince1900 MOD 7; 
//    (0=Sunday, 1=Monday, ..., 6=Saturday):



If you're after how far you are into the year in days, then just set
the base as being the 1st of Jan of the year you are interested in.

Daynum:=TRUNC(EncodeDate(year,month,day)) -
     TRUNC(EncodeDate(year,1,1)) + 1;


Do either of those help?

Dodgy.
-- 
MUSHROOMS ARE THE OPIATE OF THE MOOSES

Re: Get day of year

Postby pjwolters » Fri, 03 Jun 2005 05:00:09 GMT

Yeah Thanks!

I was indeed looking for the number of day in that year, it'sworking
perfectly,

Thnx,

Peter


Re: Get day of year

Postby Dodgy » Fri, 03 Jun 2005 18:26:41 GMT

On 1 Jun 2005 13:00:09 -0700, "pjwolters" < XXXX@XXXXX.COM >
waffled on about something:


It's worth getting to grips with Delphi's Tdatetime type, it's quite a
useful one.

It's the number of days since 12:00 am 30th December 1899.

So if you add 1 to a Tdatetime you'll have the date for the next day.

The crafty thing is it also has the hours and minutes part for
fractions of the day.

So if you wanted to know what the time would be in 12 hours time you
just take the current time in Tdatetime format (oh looks, there's one
provided for you, it's called NOW), and add 12 hours to it... 12 Hours
is half a day, so that's NOW+0.5.

All that's left is to display the new time. datetimetostr does that
for you.

Dodgy.
-- 
MUSHROOMS ARE THE OPIATE OF THE MOOSES

Similar Threads:

1.Days, Weeks, Months or Years ?

2.Today is the most depressing day of the year

According to Evning Standard.
And I can confirm thay are 100% right.

MH

-- 
borland.public.off-topic exists as a runoff for unwanted posts in the
technical groups. Enforcement of rules is deliberately minimal but
Borland reserves the right to cancel posts at any time, for any
reason, without notice.

3.Identify the first day of the current year and month

Hi

I have a table that contains orders information.
I need to filter the table to add all orders: 
 a) between the start of the year (Jan 1 of the current year)
and the current date (today) Year-to-date
 b) between the start of the current month (Day 1) and the
current date today) month-to-date

Is there a way to identify the first day of the current year and
the first day of the current month, so I can use them in the
filtering codes????

I use the following code to filter the table between two 
user selectable dates and would like to change it to filter the 
year-to-date and the month-to-date

if (DateTimePicker3->Date > DateTimePicker2->Date)
{
Table1->Filtered = false;
Table1->Filter = "Date > '" + DateTimePicker2->DateTime.FormatString(ShortDateFormat) + "'" +  "AND Date < '" + DateTimePicker3->DateTime.FormatString(ShortDateFormat) + "'";
Table1->Filtered = true;
}

thanks in advance

Rob

4.TDatetime difference in days, months and years

Hi,

I have been browsing the newsgroups for a long time trying to find if 
this issue has been resolved by somebody. I found some solutions, but
they are not very accurate. Sometimes they get one day less or they 
don't count the number of months correctly.

I've tried everything in my code with no success.

Does anybody knows a way to do it?

Thanks a lot.

5.finding the day of the year

Doews anyone know how I can find the day of the year. If I select a date 
with datepicker how can I then set about finding what number day of the 
year it is

eg: 1/1/2005 would be day 1
eg: 12/31/whatever year would be day 365 or 366 depending if it is a 
leap year.

I have had this code somewhere, but with disk crashes etc I no longer 
have it

Many thanks in advance

Anthony

6. Getting the year of a file with FTP

7. Missing for 25 years after getting on wrong bus

8. getting the actual number of the day



Return to delphi

 

Who is online

Users browsing this forum: No registered users and 3 guest