A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Date format expression in table



 
 
Thread Tools Display Modes
  #1  
Old June 10th, 2009, 01:51 PM posted to microsoft.public.access.tablesdbdesign
Yecenia
external usenet poster
 
Posts: 29
Default Date format expression in table


I need to add credit card data in my table and I need a date field to
collect and show data as "mm"/"yy".

I have tried different approaches and none worked. Please help.

Thanks.
  #2  
Old June 10th, 2009, 02:07 PM posted to microsoft.public.access.tablesdbdesign
Maarkr
external usenet poster
 
Posts: 240
Default Date format expression in table

I don't think you need a date field unless you are putting in the full date
including days, then you'll really confuse the users trying to put in a
month/year. One solution would be using an input mask like 00/00, forcing
the user to enter four digits in the display. You'll need to do some sort of
code at the form entry level to convert it to a date to see if is not expired.

"Yecenia" wrote:


I need to add credit card data in my table and I need a date field to
collect and show data as "mm"/"yy".

I have tried different approaches and none worked. Please help.

Thanks.

  #3  
Old June 10th, 2009, 02:30 PM posted to microsoft.public.access.tablesdbdesign
Klatuu
external usenet poster
 
Posts: 7,074
Default Date format expression in table

All date fields need a value for the day. Credit cards usually expire on the
last day of the month, so you coould force the day to the last day of the
month. Also, date fields are not formatted at the table level. You can use
the Format function to display them how ever you want, but the data will
still be stored as a number.
In this case, it may be better to use a text field to store the data.
--
Dave Hargis, Microsoft Access MVP


"Yecenia" wrote:


I need to add credit card data in my table and I need a date field to
collect and show data as "mm"/"yy".

I have tried different approaches and none worked. Please help.

Thanks.

  #4  
Old June 10th, 2009, 02:47 PM posted to microsoft.public.access.tablesdbdesign
Yecenia
external usenet poster
 
Posts: 29
Default Date format expression in table

If I used text I will not be able to apply logic when reporting which credit
cards are due to expire.

It sounds like I will need to change the expression on the form and figure
out the formula to make the day default to the 31st.

I would not know where to begin to figure out a formula like that.

Can anyone help with this expression?

"Klatuu" wrote:

All date fields need a value for the day. Credit cards usually expire on the
last day of the month, so you coould force the day to the last day of the
month. Also, date fields are not formatted at the table level. You can use
the Format function to display them how ever you want, but the data will
still be stored as a number.
In this case, it may be better to use a text field to store the data.
--
Dave Hargis, Microsoft Access MVP


"Yecenia" wrote:


I need to add credit card data in my table and I need a date field to
collect and show data as "mm"/"yy".

I have tried different approaches and none worked. Please help.

Thanks.

  #5  
Old June 10th, 2009, 03:06 PM posted to microsoft.public.access.tablesdbdesign
Klatuu
external usenet poster
 
Posts: 7,074
Default Date format expression in table

Here is how you can turn the text into a date.

DateSerial(Right(ExpiresOn,4),Left(ExpiresOn,2)+1, 0)

Where ExipresOn is like "03/2011"
It will return the date as 3/31/2011
It is also important you validate the data entry and be sure the user is
putting it in in the format of mm/yyyy otherwise, the above code will not
work.
--
Dave Hargis, Microsoft Access MVP


"Yecenia" wrote:

If I used text I will not be able to apply logic when reporting which credit
cards are due to expire.

It sounds like I will need to change the expression on the form and figure
out the formula to make the day default to the 31st.

I would not know where to begin to figure out a formula like that.

Can anyone help with this expression?

"Klatuu" wrote:

All date fields need a value for the day. Credit cards usually expire on the
last day of the month, so you coould force the day to the last day of the
month. Also, date fields are not formatted at the table level. You can use
the Format function to display them how ever you want, but the data will
still be stored as a number.
In this case, it may be better to use a text field to store the data.
--
Dave Hargis, Microsoft Access MVP


"Yecenia" wrote:


I need to add credit card data in my table and I need a date field to
collect and show data as "mm"/"yy".

I have tried different approaches and none worked. Please help.

Thanks.

  #6  
Old June 10th, 2009, 11:55 PM posted to microsoft.public.access.tablesdbdesign
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Date format expression in table

Or this for the 'mm/yy' type entry --
DateSerial("20" & Right(ExpiresOn,2),Left(ExpiresOn,2)+1,0)


"Klatuu" wrote:

Here is how you can turn the text into a date.

DateSerial(Right(ExpiresOn,4),Left(ExpiresOn,2)+1, 0)

Where ExipresOn is like "03/2011"
It will return the date as 3/31/2011
It is also important you validate the data entry and be sure the user is
putting it in in the format of mm/yyyy otherwise, the above code will not
work.
--
Dave Hargis, Microsoft Access MVP


"Yecenia" wrote:

If I used text I will not be able to apply logic when reporting which credit
cards are due to expire.

It sounds like I will need to change the expression on the form and figure
out the formula to make the day default to the 31st.

I would not know where to begin to figure out a formula like that.

Can anyone help with this expression?

"Klatuu" wrote:

All date fields need a value for the day. Credit cards usually expire on the
last day of the month, so you coould force the day to the last day of the
month. Also, date fields are not formatted at the table level. You can use
the Format function to display them how ever you want, but the data will
still be stored as a number.
In this case, it may be better to use a text field to store the data.
--
Dave Hargis, Microsoft Access MVP


"Yecenia" wrote:


I need to add credit card data in my table and I need a date field to
collect and show data as "mm"/"yy".

I have tried different approaches and none worked. Please help.

Thanks.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.