I currently have a interger field with this format (YYYYMMDD) Example 20071118
I want to automate a weekly report Sun - Sat, therefore do not want to hard code the date. I want to say (Current Date - 7 days).
I have tried multiple things but they do not work.
Please help!
Thank YOU
5 1703
Hi,
"Current Date - 7 days" only works on date or timestamp columns. If you stick to your integer field, you need to transform this date value to integer like: - ... where
-
my_int_date >=( year(Current Date - 7 days) * 10000
-
+ month(Current Date - 7 days) * 100
-
+ day(Current Date - 7 days) * 1 )
Regards, Bernd
Hi,
"Current Date - 7 days" only works on date or timestamp columns. If you stick to your integer field, you need to transform this date value to integer like: - ... where
-
my_int_date >=( year(Current Date - 7 days) * 10000
-
+ month(Current Date - 7 days) * 100
-
+ day(Current Date - 7 days) * 1 )
Regards, Bernd
Wow!! It works.
Please explain how it works.
For current date I am using Nov 20. So if I use the formula you gave I get
Year(20-7)*1000=13000
Month(20-7)*100=1300
Day(20-7)*1=13
13000+1300+13=14313 (How does 14313 equal Nov 13 ?
Thanks again. Your a life Saver!
Hi,
glad to hear you're saved. But your calculation is slightly wrong. Assumed today is the 20th of november, then current_date() would give '2007-11-20' as result. Put this into your calculation to see what happens: -
-> current_date() - 7 days
-
= '2007-11-20' - 7 days
-
= '2007-11-13'
-
-
Year( '2007-11-13' ) * 10000 = 2007 * 10000 = 20070000
-
Month( '2007-11-13' ) * 100 = 11 * 100 = 1100
-
Day( '2007-11-13' ) * 1 = 13 * 1 = 13
-
-------------------------------------------------------
-
Sum = 20071113
-
Regards, Bernd
Hi,
glad to hear you're saved. But your calculation is slightly wrong. Assumed today is the 20th of november, then current_date() would give '2007-11-20' as result. Put this into your calculation to see what happens: -
-> current_date() - 7 days
-
= '2007-11-20' - 7 days
-
= '2007-11-13'
-
-
Year( '2007-11-13' ) * 10000 = 2007 * 10000 = 20070000
-
Month( '2007-11-13' ) * 100 = 11 * 100 = 1100
-
Day( '2007-11-13' ) * 1 = 13 * 1 = 13
-
-------------------------------------------------------
-
Sum = 20071113
-
Regards, Bernd
That is really cool! Awesome.
My only concern is when I run the report on January 6, 2008 and go back 7 days, is the system smart enough to know I want December 30 to 31st and January 1st to 5th. ?
Have a great Thanksgiving!
My only concern is when I run the report on January 6, 2008 and go back 7 days, is the system smart enough to know I want December 30 to 31st and January 1st to 5th. ?
Yes, it is. That's why there's the "+- x days/minutes/etc" possibility. After all, inside DB2 date, time and datestamp fields are nothing else than integers. But just not the way you seem to need them.
Have a great Thanksgiving!
Thank you, the same to you.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: Russell |
last post by:
I'm having a fit with a query for a range of dates. The dates are
being returned from a view. The table/field that they are being
selected from stores them as varchar and that same field also...
|
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...
|
by: Joe User |
last post by:
Hi all....I have a feeling this is going to be one of those twisted query
questions, but here it goes anyways....
I want to generate a report that shows the chronology of events (represented
by...
|
by: Douglas |
last post by:
I have a Vehicle MOT field in my table which i have as a Date field
I dont really want to hold the year, just 'dd mmm' as MOTs are the
same date every year.
I have the field on my form as a...
|
by: Matt |
last post by:
I have a number of TextBox controls bound to date fields in my
application, and have come across a disconcerting issue: When you are
entering data into the bound field, if you enter any string that...
|
by: x |
last post by:
hi
i am a pilot by profession. i want to create a database of my logbook
using ms access 2002. i am facing a problem regarding the format of
time field. when i select "Data/Time" data type for my...
|
by: M Skabialka |
last post by:
I am creating my first Visual Studio project, an inventory database. I have
created a form and used written directions to add data from a table to the
form using table adapters, data sets, etc.
...
|
by: Brad Pears |
last post by:
I am working on a vb.net 2005 project using sql server 2000 as the backend .
I am having a bit of problems with date variables... Here is the scenario...
I have a table that includes a couple...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
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,...
| |