SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Selecting rows according to todays date.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AdamWest
Constraint Violating Yak Guru

USA
353 Posts

Posted - 08/20/2013 :  10:13:45  Show Profile  Reply with Quote
I have to select rows based on if the transaction date = todays date.

The column is defined as numeric 8 with 0 decimal.

Can you show me how to code for todays date with such a column?

James K
Flowing Fount of Yak Knowledge

3706 Posts

Posted - 08/20/2013 :  10:20:17  Show Profile  Reply with Quote
quote:
Originally posted by AdamWest

I have to select rows based on if the transaction date = todays date.

The column is defined as numeric 8 with 0 decimal.

Can you show me how to code for todays date with such a column?

Can you give some examples of the data? For example, how is today's date represented in the numeric 8 column?
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

USA
353 Posts

Posted - 08/20/2013 :  10:23:40  Show Profile  Reply with Quote
yes, on the server it is represented as this:

19,991,216




quote:
Originally posted by James K

quote:
Originally posted by AdamWest

I have to select rows based on if the transaction date = todays date.

The column is defined as numeric 8 with 0 decimal.

Can you show me how to code for todays date with such a column?

Can you give some examples of the data? For example, how is today's date represented in the numeric 8 column?

Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3706 Posts

Posted - 08/20/2013 :  10:45:33  Show Profile  Reply with Quote
quote:
Originally posted by AdamWest

yes, on the server it is represented as this:

19,991,216




quote:
Originally posted by James K

quote:
Originally posted by AdamWest

I have to select rows based on if the transaction date = todays date.

The column is defined as numeric 8 with 0 decimal.

Can you show me how to code for todays date with such a column?

Can you give some examples of the data? For example, how is today's date represented in the numeric 8 column?



I am not familiar with that representation of dates. What is the formula/process you would use to convert 19,991,216 to August 20, 2013?

If you don't have that information, hopefully someone else on the forum may know.
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

USA
353 Posts

Posted - 08/20/2013 :  10:54:39  Show Profile  Reply with Quote
James, I am not looking to convert the date.

I am looking for select only the current date. I am going to make a VIew, so that the Crystal Report would only get the current date. The user runs this every day and is only interested in the current date. so it would only select 20,130,820 if run today.

Edited by - AdamWest on 08/20/2013 10:56:42
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 08/20/2013 :  11:19:20  Show Profile  Reply with Quote
http://www.sqlservercentral.com/articles/Best+Practices/61537/
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Here is one way:
SELECT CAST(CONVERT(VARCHAR(8), GETDATE(), 112) AS DECIMAL(8,0))


Edited by - Lamprey on 08/20/2013 11:23:38
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

USA
353 Posts

Posted - 08/20/2013 :  12:02:14  Show Profile  Reply with Quote
What is GETDATE? is that for the current date?
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3706 Posts

Posted - 08/20/2013 :  12:23:50  Show Profile  Reply with Quote
Yes, GETDATE gets you current date and time. You will see what it does if you run the query "SELECT GETDATE()". The CONVERT function formats that to a string according to the format specifier (112) in this case: http://technet.microsoft.com/en-us/library/ms187928.aspx
Go to Top of Page

corbingravely
Starting Member

1 Posts

Posted - 12/13/2013 :  04:53:39  Show Profile  Reply with Quote
You can do this using the foreign key. You can set the unique Id as the one you prefer to be the reference point and call the rest of the table objects using that key as the major object.








Edited by - corbingravely on 05/16/2014 07:25:05
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000