Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL command with date selection 1

Status
Not open for further replies.

mpemberton

Programmer
Mar 5, 2002
37
US
This should be helpful to those trying to write a SQL command and doing a date selection.

Here is an example of using the date in the SQL command:

&quot;SELECT InvoiceDate, InvoiceNumber, SOConfirmTo, SOCustomerPONumber, SOSalesOrderNumber, SONonTaxableSalesAmt FROM ARN_InvHistoryHeader WHERE (InvoiceDate>={d '&quot; & byear & &quot;-&quot; & bmonth & &quot;-&quot; & bday & &quot;'}) AND (InvoiceDate<={d '&quot; & eyear & &quot;-&quot; & emonth & &quot;-&quot; & eday & &quot;'}) ORDER BY InvoiceDate&quot;


Please note the variables used:
byear is the beginning year
bmonth is the beginning month
bday is the beginning day
eyear is the ending year value, etc.

Also make sure you use 2 digit months and days in for all values. Like 01, 02, 03, etc.


If that isn't the most unusual way of specifying dates. Anyway, I hope this helps.

Thanks,
Mark Pemberton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top