Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

4-digit date

Posted on 1997-11-25
5
Medium Priority
?
146 Views
Last Modified: 2010-04-04
In trying to comply with Y2K, I have set my BDE configuration to use 4 digit dates.  However, I don't know how to save the date to the date field of a record in a table.  I have used:
      tableDATE.asDateTime := Date;
and it always seems to save it in mm/dd/yy format.  Any guidance on how to save it in mm/dd/yyyy format?
0
Comment
Question by:northstar
5 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1351813
If you are using Delphi 2 or later it should save the date & time using 4 digits for the year.  It may only display 2 year digits (if your Control Panel is set up this way) but internally all 4 year digits are stored.

JB
0
 
LVL 1

Expert Comment

by:jackb022197
ID: 1351814
Also check your BDE configuration and set the FOURDIGITYEAR parameter to True.
0
 

Author Comment

by:northstar
ID: 1351815
I am using Delphi 1.02 and have set the BDE config to FOURDIGITYEAR.
0
 

Accepted Solution

by:
mshaer earned 150 total points
ID: 1351816
Dates in Delphi are in fact stored as numbers (Julian Dates).
They are recorded as a time difference from a specified date.
This means that regardless of how they are displayed, the
complete date is still being stored.

Try using

DecodeDate(Date, yearw, monthw, dayw);

(where Date is a DateTime and yearw, monthw and dayw are words)

and decodeTime

from the documentation :

type TDateTime = type Double;

Description

Delphi stores date and time values in the TDateTime type. The integral part of a TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of a TDateTime value is the time of day.

Following are some examples of TDateTime values and their corresponding dates and times:
0               12/30/1899 12:00 am
2.75               1/1/1900 6:00 pm
-1.25               12/29/1899 6:00 am
35065               1/1/1996 12:00 am

procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word);

You can get hold of the entire date, to test this put a button and a label on your form and then in the button event write

var
  yearw, monthw, dayw: word;
begin
  DecodeDate(YourDateHere, yearw, monthw, dayw)
  LabeName.Caption := IntToStr(dayw) + '/' + IntToStr(monthw) + '/' + IntToStr(yearw);
end;

This will display your date as dd/mm/yyyy

for the help details look under TDateTime (type) in the Delphi
Help

good luck
0
 

Author Comment

by:northstar
ID: 1351817
I have solved it myself by setting ShortDateFormat := 'mm/dd/yyyy'
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question