473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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('1997-10-04 22:23:00', '%W %M %Y');

It returns 'Saturday October 1997''.

Thanks,

Bing

Apr 17 '06 #1
5 61163
du****@gmail.com 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('1997-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.com 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('1997-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_field( $qry_getdetail )) ) {
echo "<b>". $f->name ." (" . $f->type . ") , </b>";
}
===

If the query is:

$qry_getdetail = odbtp_query("SELECT end_date FROM qryProjectDetail");

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

If the query is:

$qry_getdetail = odbtp_query("SELECT FORMAT(end_date, 'mmmm d yyyy')
FROM qryProjectDetail");

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
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
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)....
1
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...
0
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
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
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...
4
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...
3
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...
2
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.