Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

4-digit date

Posted on 1997-11-25
5
Medium Priority
?
145 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

670 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