473,320 Members | 1,950 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,320 software developers and data experts.

date issue in .adp file

Hi,

I have an ADP file that stores dates in a datetime field type and I want to
query the table for all records for a single date (ie. ignore the time). I
want it to automatically return all records for a single day that is 7 days
prior to todays date.(in dd/mm/yyyy format)

I have looked in books on-line, and have had some success with the CONVERT
function, but I cannot get the results consistently as dd/mm/yyyy format.

Can anyone offer suggestions?

regards
SB
Nov 13 '05 #1
1 1833
Scott Berry wrote:
Hi,

I have an ADP file that stores dates in a datetime field type and I want to
query the table for all records for a single date (ie. ignore the time). I
want it to automatically return all records for a single day that is 7 days
prior to todays date.(in dd/mm/yyyy format)

I have looked in books on-line, and have had some success with the CONVERT
function, but I cannot get the results consistently as dd/mm/yyyy format.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Perhaps:

WHERE date_column BETWEEN
CONVERT(DATETIME, CONVERT(VARCHAR(10),GETDATE(),101)) - 7
AND (CONVERT(DATETIME, CONVERT(VARCHAR(10),GETDATE(),101)) - 7) + 1

The CONVERT(VARCHAR(10)...) turns the date-time into the date only.

The last conversion that adds 1 to the result is used to span the date 7
days previous to the current date. By using a span of date-times you
get all times in one date. I.e., Midnight (00:00) to the next midnight
(24:00).

The same example w/ conversions (getdate() returns 12 Feb 2005):

WHERE date_column BETWEEN '2005-02-05 12:00AM' And '2005-02-06 12:00AM'

To display in "dd/mm/yyyy" format you'll have to use the CONVERT()
function in the SELECT clause:

SELECT CONVERT(VARCHAR(10), date_column, 103) As date_value, ...
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQg5T64echKqOuFEgEQJCmQCg8SA8qB+FrzQ0L3F5ApK3Aj EVgaoAoMp5
7WQPe+uqKqbrkngRKJz4vvEg
=4BCU
-----END PGP SIGNATURE-----
Nov 13 '05 #2

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

Similar topics

3
by: Yannick Turgeon | last post by:
Hello all, One of our PHP program bugged recently. I've reduced the problem to this: April 4th! Anybody can tell me if I'm doing something wrong? Why April 4th is not printing but replaced by...
3
by: Jay | last post by:
I previously posted this question under Visual Basic newsgroup, but was advised to re-post here. I'm hoping someone can help me solve an issue I'm having with VB.Net and Access 2000. Here's...
4
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them...
4
by: wil | last post by:
Dear All, In the linux platform, is there anyway I can in a C program change the file create date? Thanks, wil.
9
by: Shapper | last post by:
Hello, I created a dataset from a XML file. One of the dataset fields is . In an ASP:Repeater I am displaying the field. <%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %> The...
5
by: NickCR_04 | last post by:
Hi all, I am (using ASP.net 2.0 in Visual Web developer 2005 Express Edit) trying to set up an asp front end to a music DB which has 2 main tables: 1) MUSIC - containing music release...
3
by: AA Arens | last post by:
I created at a Word filke containing field and the data is from my database (via ODBC). One of the fields is Date. The format in the database is dd-mm-yyyy (I checked it in VB code), but in the...
2
by: webmonkie | last post by:
Hi, I am hoping someone can point me in the right direction as I have been trying to fix this issue for a good while now. I am trying to take information out of a xml file using php and parsing it...
9
by: Frank Swarbrick | last post by:
I've probably asked this before, but I can't remember the answer! One can use the DECIMAL function to convert a date to a decimal. For instance values decimal(current_date) returns 20080528. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.