Solved

URGENT! MS ACCESS! Querying a Date/Time Field - Need ASAP!

Posted on 2006-07-14
6
153 Views
Last Modified: 2013-12-24
I have a field saved as

7/6/2006 9:00:00 AM

but when I dump the var I get

2006-07-06 09:00:00.0

I need the time as well! Very Critical!

Initial Query
         <cfquery datasource="#Request.App.DS#" name="GetEvent">
         SELECT EventID,
                EventTypeID,
                EventName,
                StartDateTime,
                EndDateTime,
                EventShortDesc,
                EventDescription,
                Location,
                EventURL,
                EventImage,
                ContactName,
                ContactPhone,
                ContactEmail,
                AllDayFlag
           FROM Event
          WHERE EventID = #URL.EventID#
         </cfquery>

I know you can do this via Oracle...I need it for access...
                TO_DATE(TO_CHAR(StartDateTime, 'MM/DD/YYYY HH24:MI'), 'MM/DD/YYYY HH24:MI') AS StartDateTime,
                TO_DATE(TO_CHAR(EndDateTime, 'MM/DD/YYYY HH24:MI'), 'MM/DD/YYYY HH24:MI') AS EndDateTime,






0
Comment
Question by:firstbankak
  • 3
6 Comments
 
LVL 15

Expert Comment

by:danrosenthal
ID: 17111125
<CFOUTPUT>
StartDateTime:
#dateformat(GetEvent.StartDateTime,"MM/DD/YYYY")# #timeformat(GetEvent.StartDateTime,"HH:mm")#
<BR>

EndDateTime:
#dateformat(GetEvent.EndDateTime,"MM/DD/YYYY")# #timeformat(GetEvent.EndDateTime,"HH:mm")#
</CFOUTPUT>
0
 
LVL 12

Expert Comment

by:mkishline
ID: 17111162
You should be able to do either:

<cfquery datasource="#Request.App.DS#" name="GetEvent">
         SELECT EventID,
                EventTypeID,
                EventName,
                Format(StartDateTime,"mm/dd/yyyy hh:nn") AS StartDateTime,
                Format(EndDateTime,"mm/dd/yyyy hh:nn") AS EndDateTime,
                EventShortDesc,
                EventDescription,
                Location,
                EventURL,
                EventImage,
                ContactName,
                ContactPhone,
                ContactEmail,
                AllDayFlag
           FROM Event
          WHERE EventID = #URL.EventID#
         </cfquery>

And if that doesn't work, you can always do it when you return the values:
<cfoutput query="GetEvent">
   Start Date: #DateFormat(StartDateTime,"mm/dd/yyyy")# #TimeFormat(StartDateTime,"hh:mm")#
   End Date: #DateFormat(EndDateTime,"mm/dd/yyyy")# #TimeFormat(EndDateTime,"hh:mm")#
</cfoutput>
0
 
LVL 12

Expert Comment

by:mkishline
ID: 17111211
Sorry dan, didn't mean to duplicate your stellar advice ;-)
0
 
LVL 12

Accepted Solution

by:
mkishline earned 500 total points
ID: 17406789
It seems as though both dan and myself offered solutions that would solve firstbankak's problem. Either a point split here (or points to dan if my sql solution wasn't clear enough, since he was faster on the draw) seems most appropriate.

Thanks,
mkishline
0
 

Author Comment

by:firstbankak
ID: 17408001
Please close this question.  The individual who initiated it with me is no longer employed here.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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