473,472 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Return Yesterdays Sales

Hi,

I have a table with all my sales from yesterday. In the field i have the date of the order stored in this format: 1286193719

I want to run a statement on the database to find all the sales from yesterday.

I thought this would work:

Expand|Select|Wrap|Line Numbers
  1. "SELECT fTotalPrice FROM te5_tbShop_Orders WHERE tmOrderDate = CURRENT_DATE() - INTERVAL 1 DAY"
or

Expand|Select|Wrap|Line Numbers
  1. "SELECT fTotalPrice FROM te5_tbShop_Orders WHERE date(tmOrderDate) = CURRENT_DATE() - INTERVAL 1 DAY"
But it returns 0 even though there are 20 sales yesterday.

Please can someone advise?

Cheers,
Adam
Oct 4 '10 #1
1 1460
code green
1,726 Recognized Expert Top Contributor
The date and time functions will only work on the date and time data types.
That looks like a unix timestamp which is an integer.

So it is not an order date it is an order date and time to the nearest second.

This can be converted using FROM_UNIXTIME() which still returns seconds.
This means you need to select a time period midnight-midnight, so BETWEEN rather than '=' should be used.

You could try
Expand|Select|Wrap|Line Numbers
  1. WHERE tmOrderDate = CURRENT_DATE() - INTERVAL 1 DAY = DATE(FROM_UNIXTIME())
Oct 5 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Mark Anthony | last post by:
ok so first i will give write the question out, my code, the db structure, then what is going wrong. Write a report to return the top store in terms of Sales Dollars for each month sales have...
0
by: Dyego Souza do Carmo | last post by:
The sales team are down ? I'm trying to order MySQL-PRO licences and the team not return my emails... i trying with sales@mysql.com and gerardo@sales.com gerardo is out ? this is my...
6
by: Mark | last post by:
Hi, Does anyone know where i can get some javscript code to work out yesterdays date Thanks Mark
1
by: laurenq uantrell | last post by:
I am trying to construct a query that sums sales by salespersons and only returns a list of salespersons that have a sum of sales lower than the previous month for whatever date rane is selected....
1
by: VB Programmer | last post by:
How can I get yesterdays date? I would think now.date.subtract(1) works, but it doesn't. Thank.
8
by: Anonmyous | last post by:
Hello, how can I get the yesterdays date? Thanks for any suggestions and tips.
2
by: kansaskannan | last post by:
I have an Access 2000 database which lists customers by name, and how much (in dollars) they have purchased of various products. How do I write a SQL statement to select customers who make up the...
3
by: CK | last post by:
USE AdventureWorks GO -- Retrieve order manifest SELECT SalesOrder.SalesOrderID,
5
code green
by: code green | last post by:
I need to do a query something like SELECT * FROM invoices WHERE date= 'yesterdays date'It is not as simple as one might think which means ideas I have looked at vary widly. Could someone please...
4
by: wutang | last post by:
Create a program that displays the sum of the sales amounts made in each of four regions (North, South, East, West) during a three month period. The program should display the total sales made during...
0
marktang
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,...
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
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...
1
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.