Solved

Formating Date

Posted on 2003-11-26
8
243 Views
Last Modified: 2013-12-24
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
Comment
Question by:Angela030399
[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
  • 4
  • 3
8 Comments
 
LVL 12

Expert Comment

by:jyokum
ID: 9826471
how are you inserting it into access, what's your query look like?
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9826832
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
 
LVL 12

Expert Comment

by:jyokum
ID: 9826910
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
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 25

Expert Comment

by:James Rodgers
ID: 9827220
>>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
 
LVL 12

Expert Comment

by:jyokum
ID: 9827246
which is exactly why I asked the question "how are you inserting it into access, what's your query look like? "
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9827320
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
 
LVL 17

Accepted Solution

by:
anandkp earned 500 total points
ID: 9829569
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
 
LVL 12

Expert Comment

by:jyokum
ID: 10049748
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

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 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