Solved

4-digit date

Posted on 1997-11-25
5
141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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