Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Field - Possible to Store Year Only?

Status
Not open for further replies.

LaCour

MIS
Jul 15, 2004
53
0
0
US
Is it possible to only store the year in a date field

YYYY?

If this is not possible I will us a number field and allow the user ot select from pulldowns on the form.

Thanks in advance
Blair

ps
I think I remember doing thiw with oracle using to_char function from sysdate into a char field variable, then by going back to a date field variable with the the to_date function but masking it such that only the year would be stored.
 
Hi,

A DATE by definition is a DATE -- and WHAT IS A DATE?

Year, Month and Day!

You can determine the Year value from a DATE and store the Year value, but its NOT A DATE. It's an INTEGER or sumthin'!

Skip,
[sub]
[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue][/sub]
 
BTW,

The FORMATTED DATE that you and I like to see is just that -- a FORMAT.

A Date Value is REALLY a NUMBER -- like today is 38271 in MS Applications, where the DATE is stored as an integral number starting with 1, on 1/1/1900 and incrimenting be 1 each day since.

Skip,
[sub]
[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue][/sub]
 
PHV,

If I format the value 1, I get 1/1/1900.

???

Skip,
[sub]
[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue][/sub]
 
Skip, in my immediate window:
? format(1,"mm/dd/yyyy")
12/31/1899
Note: French TZ ????
 
Ok, I understand ... using formatting, we can manipulate what we show and only show YYYY. Conversely, what mask would I use that would only permit the user to enter YYYY? I understand that I will store all aspects of the date YYYYMMDDSS, but I am only intereted in the YYYY.

The conext is entering financial information (e.g. development infrastructure expenses / year, production infrastructure expenses / year)

That being said, I only want them to enter the year and they will expect to only enter the year (or they will be confused I am guessing). When I am creating reports on this information, I will only use the YYYY that is stored - so I could use various functions to get at what I'm interested in.

That being said, I think this will easier if I just use a number field and allow them to choose from a pulldown(1999, 2000, 2001, 2002, 2003 etc)

Let me know your thoughts.

Thanks
Blair
 
If you only permit a user to enter YYYY, then they are NOT entering a DATE. You are entering an INTEGER.

Skip,
[sub]
[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue][/sub]
 
PHV,

Interesting.

There seems to be a disconnect between Excel Sheet Formatting and VB Format. Is this related to the miscalculation regarding the leapyear in 1900?

Skip,
[sub]
[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue][/sub]
 
Nope ... not related to leap year ... I am just trying to caputre financial information, year by year.

I think I am goin to use a number field ... let me know if you guys think I should do different.

Thanks
Blair
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top