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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

Formating Date

I am using a (MS Access) database  to store credit card expired date as 06/04. When I type expired date in text field (Example: 06/04) it stores date in Access as 7/12/1894. What is the syntax storing date as 06/04 or 06/2000 using CF.

Thanks, Angela
0
Angela030399
Asked:
Angela030399
  • 4
  • 3
1 Solution
 
jyokumCommented:
how are you inserting it into access, what's your query look like?
0
 
James RodgersWeb Applications DeveloperCommented:
it's not the insert it's access

don't use the date time datatype for the field use text and strore the date as 06/04

and use cf to format it on output if neccessry
0
 
jyokumCommented:
Jester_48,
why not use a date field? 06/04 is just assumed to be 06/01/04 00:00:00. doing it this way make it real easy to do date math against this field... things like quering all the accounts whose credit card expires in the next 60 days.
0
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 
James RodgersWeb Applications DeveloperCommented:
>>why not use a date field? 06/04 is just assumed to be 06/01/04 00:00:00

not always, access can be strange when interacting with certain datatypes like date/time, the program sometimes makes assumptions about what the data you are trying to enter *should* be

open an access database and create a new table with a field using date time, set the format to anything, access always tries to convert the input to a usable format which can have some strange results, so if you input a two part date such as 06/04 you can get the following results, depending on which format you have set, such as

7/12/1894
06/03
06/04/2004

noe of which is even close to what you need
but if you format the date before entering, what do you use as the 'day' of the date? the first day of the month, then on june second your card would be denied, end of the month, then you need a formula to calculate the last day of the month before inserting

if you store the two part date as text then you will always have it in the appropriate cc format
0
 
jyokumCommented:
which is exactly why I asked the question "how are you inserting it into access, what's your query look like? "
0
 
James RodgersWeb Applications DeveloperCommented:
i am not questioning your request, merely stating some of the peculiarities of access will affect the process of storing a 2 part date as opposed to a regular date
0
 
anandkpCommented:
try & do this

<CFSET USERDATE = "06/04">
<CFSET USERDATE = CreateDate(year(now()),'06','04')><!--- Converting it to a properdate format Year / Month / Day --->

<CFQUERY NAME="Ins_DateInAccess" DATASOURCE="Dsn">
    Insert into table (name,mydate_field)
      values
      (<CFQUERYPARAM CFSQLTYPE="cf_sql_varchar" VALUE="anandkp">,
      <CFQUERYPARAM CFSQLTYPE="cf_sql_date" VALUE="#UserDate#">)
</CFQUERY>

Now with a properdate in ur database - like jyokum said "doing it this way makes it real easy to do date math against this field... things like quering all the accounts whose credit card expires in the next 60 days"

HTH

K'Rgds
Anand

PS : I wld not advice on storing dates as plain text in formats "06/04 or 06/2000" - dosent help the cause !
0
 
jyokumCommented:
Angela,
This has been open 40 days and there hasn't been a comment added in 40 days.
Please select a comment as the solution or give us an update.

jyokum
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now