473,761 Members | 4,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what function to use to convert date format in query?

Hello everyone,

There is a field of DATETIME type in our Access 2000 database. PHP is
used to query the data and display the query results on the web. Does
Access provide any function that can convert DATETIME field into a more
user friendly format directly in query? I can do the following in
MySQL. How should it be done in Access?

SELECT DATE_FORMAT('19 97-10-04 22:23:00', '%W %M %Y');

It returns 'Saturday October 1997''.

Thanks,

Bing

Apr 17 '06 #1
5 61222
du****@gmail.co m wrote:
Hello everyone,

There is a field of DATETIME type in our Access 2000 database. PHP is
used to query the data and display the query results on the web. Does
Access provide any function that can convert DATETIME field into a
more user friendly format directly in query? I can do the following
in MySQL. How should it be done in Access?

SELECT DATE_FORMAT('19 97-10-04 22:23:00', '%W %M %Y');

It returns 'Saturday October 1997''.


Format([DateFieldName], "dddd mmmm yyyy")

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Apr 17 '06 #2
Rick Brandt wrote:
du****@gmail.co m wrote:
Hello everyone,

There is a field of DATETIME type in our Access 2000 database. PHP is
used to query the data and display the query results on the web. Does
Access provide any function that can convert DATETIME field into a
more user friendly format directly in query? I can do the following
in MySQL. How should it be done in Access?

SELECT DATE_FORMAT('19 97-10-04 22:23:00', '%W %M %Y');

It returns 'Saturday October 1997''.


Format([DateFieldName], "dddd mmmm yyyy")


Thanks for the response. The date got formated correctly in the result
set. However the name of the field got changed.

The following PHP code snippet is used to return the name of the field:

===
/* Show fields' names in the result set*/

while( ($f = odbtp_fetch_fie ld( $qry_getdetail )) ) {
echo "<b>". $f->name ." (" . $f->type . ") , </b>";
}
===

If the query is:

$qry_getdetail = odbtp_query("SE LECT end_date FROM qryProjectDetai l");

The result is: end_date (DATETIME). And the value of 'end_date'
returned is 'Object'.

If the query is:

$qry_getdetail = odbtp_query("SE LECT FORMAT(end_date , 'mmmm d yyyy')
FROM qryProjectDetai l");

The name of the field and its type changed to be: Expr1000 (VARCHAR).
And the value of 'end_date' is correct.

Why is that? I need both the field's name and value to be correct.

Thanks,

Bing

Apr 19 '06 #3
Bing:

The Format function converts a date to a string, formatted in the way
you specify, which is why you're getting a different data type. If you
need BOTH the field for your PHP and the nicely formatted text, I would
suggest that you add the end_date field back to your query. You can
rename the format results by replacing the Expr1000 with text_end_date
in your SQL. So you'll have SELECT (Format([end_date],"dddd mmmm
yyyy")) AS text_end_date instead of SELECT (Format([end_date],"dddd
mmmm yyyy")) AS Expr1000. Use the end_date whenever you need the
datetime value, use the text_end_date when you need to display it for
the user.

HTH,
Jana

Apr 19 '06 #4
Jana wrote:
Bing:

The Format function converts a date to a string, formatted in the way
you specify, which is why you're getting a different data type. If you
need BOTH the field for your PHP and the nicely formatted text, I would
suggest that you add the end_date field back to your query. You can
rename the format results by replacing the Expr1000 with text_end_date
in your SQL. So you'll have SELECT (Format([end_date],"dddd mmmm
yyyy")) AS text_end_date instead of SELECT (Format([end_date],"dddd
mmmm yyyy")) AS Expr1000. Use the end_date whenever you need the
datetime value, use the text_end_date when you need to display it for
the user.


Thanks a lot for the help, Jana. That makes sense. I forgot field's
name could be customized using AS.

Bing

Apr 19 '06 #5
You're welcome, and good luck!

Jana

Apr 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4068
by: ohaya | last post by:
Hi, I'm working with a date string with a format as follows: Sat Dec 25 21:32:59 EST 2004 and I want to compare it to another date string of the format: 7/28/2004
2
5206
by: Annie D via AccessMonster.com | last post by:
Hi, I am using the following SQL statement courtesy of access monster user: 'Terry Kreft ' to convert dates from a text format (20020331 00:00:00) to a recognised date/time format (31/03/2002). SELECT END_DTTM, Left(,4) AS END_DTTM_year, Mid(,5,2) AS END_DTTM_month,
1
11433
by: prabhunew2005 | last post by:
I am using postgres,php in web designing. I have to convert date entered in MM-DD-YYYY format to YYYY-MM-DD format. I have to use resulting date format in my search sql. I used todate method. But i did not get correct answer. Can you give me a solution for this? (37 minutes ago )
0
1632
by: Swati Gunda | last post by:
Hello, I am working on C#. I want to convert system date which is by default in mm/dd/yyyy format into dd/mm/yyyy format. If you know the solution then plz reply me immediately. Thanks Swati
2
3934
by: ManickavasagamSathiskumar | last post by:
hai I have one text box in asp page it for date entry field(dd/mm/yyyy)format user entered. But when i store in database it will store (mm/dd/yyyy) format how to change in asp.
7
2080
chandru8
by: chandru8 | last post by:
I read the date from Notepad and convert it into date using Dateserial function. I try to convert it into my desired format like fomat( ,"dd/mm/yy") but I am unable to do that. Dim fs As New FileSystemObject Dim ts As TextStream Dim str As String Dim int1 As Integer Dim dt1 As String Dim dt As Date Dim date1 As Date Dim DATE2 As Date
4
4528
by: thomasc1020 | last post by:
This is regarding VB.NET 2003. Variable 'Date' is a string and it contains date information in this format: "DEC/05/2007". Now I am trying to convert the format as "2007-12-05". Is it possible to convert the arrangement using 'Format' method? If so, please educate me how I can do such operation. Thank you!
3
24436
Chittaranjan
by: Chittaranjan | last post by:
Hi All, I am not sure how to change the date format in PostgreSQL. I have the dates stored in the database as yyyy-mm-dd HH:MM:SS+TimeZone to get the GMT time (Ex: 2008-02-28 14:03:23+05:30). But I want these dates to be shown in the following format: dd/mm/yyyy HH:MM:SS TimeZone (Ex: 28/02/2008 14:03:23 IST)So now while I am trying to fetch the dates from the database I am using to_char() as below: to_char(field_name, 'DD/MM/YYYY...
2
12893
by: anoop s | last post by:
Hi, In my web application I want fetch data from fixed width text file. I am using OLEDB connection for retrieving data. But the problem is the date format is dd/mm/yyyy in text file. Can I change it into mm/dd/yyyy format while fetching. Thanks in advance.
0
9975
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9909
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8794
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6623
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5241
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3889
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2765
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.