473,394 Members | 2,168 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,394 software developers and data experts.

How to separate Date in query?

yosiro
34
I want to seperate date on query field.
Eg. in the field date show 12/3/2012
so i want to seperate just year in a new field

in excel we known MID LEFT RIGHT function
Sep 21 '12 #1

✓ answered by Seth Schrock

If the date 12/3/2012 is in a field called DateField, then you would have the following in your query:

Expand|Select|Wrap|Line Numbers
  1. Year(DateField) AS YearField
You can do the same thing with Month() and Day().

Note: Don't name a field Year, Month, or Day, or Date even as an alias (the part after the AS) as these are reserved names and can cause problems when trying to reference them. Hence, my naming it DateField and YearField. You can can change the alias to be more descriptive for its use.

1 5011
Seth Schrock
2,965 Expert 2GB
If the date 12/3/2012 is in a field called DateField, then you would have the following in your query:

Expand|Select|Wrap|Line Numbers
  1. Year(DateField) AS YearField
You can do the same thing with Month() and Day().

Note: Don't name a field Year, Month, or Day, or Date even as an alias (the part after the AS) as these are reserved names and can cause problems when trying to reference them. Hence, my naming it DateField and YearField. You can can change the alias to be more descriptive for its use.
Sep 21 '12 #2

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

Similar topics

6
by: carverk | last post by:
Hello All I'm in the middle of moving a MS Access DB to a MySql backend. I have figured out about 90% of the problems I have faced, execpt for this one. I have 3 Queries, which pull records...
4
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...
3
by: Josh | last post by:
I need a query that will select the closest date. I have to tables Pricing and InventoryItem. tblInventoryItem InventoryItemID <- Pk Description tblPricing
3
by: Jim | last post by:
I'm having a problem with a date query..im trying to pull customer data based on a date specified from a form to 3 months prior to the date specified. So lets say in the form I specified 1/2/2004....
3
by: colleen1980 | last post by:
Hi: Data in my table is in that format. How to i separate date with time. 11/9/2006 10:10:46 AM Thank You.
5
by: atiq | last post by:
i am trying to update a field within a table. But i dont want to update the whole of the data within the field just one part of it. The field is the Tutor Group for students in the format 7B, 7D,...
7
by: P3Eddie | last post by:
Hello all! I am new to Access, SQL and database management, and need help with an SQL statement in Access. I have 3 fields, BirthDay BirthMonth BirthYear
2
by: scott | last post by:
Hi Everyone, I have a table which has many fields in it but I need to pull some specific info via a query and I don't know if it's possible. I want to run a query which includes two tables....
9
by: Millie18 | last post by:
Hi, I’m trying to set up a query to find all dates on or between a start and end date. Table name and field names I’ve used: Tbl_bookings Booking No Boarding Arrival Date Boarding Departure...
13
by: dizzydangler | last post by:
Just a quick question...I'm running an MS Access 2007 db that tracks appointments in a single table. Date and time are entered as separate fields in short date (mm/dd/yyyy) and short time (hh:mm)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
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...

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.