?
Solved

date string..put it according to month, day and year

Posted on 2008-06-11
9
Medium Priority
?
209 Views
Last Modified: 2013-11-27
I have three field

Date                   Month               day            year
1-30-2008
12-11-2006
1-15-2007

my other fields have no records. Just the Date field has records. How would I divide the date so it updates the corresponding fields accordingly
something like this

Date                   Month               day            year
1-30-2008             1                     30            2008
12-11-2006          12                    11            2006
1-15-2007             1                     15            2007

Thanks

0
Comment
Question by:syedasimmeesaq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 3

Expert Comment

by:NIMTUG_Simon
ID: 21764856
Select [Date], Month([Date]) as [Month], Day(]Date]) as [Day], Year([Date]) as [Year] from Table

You can add these as calculated fields in your table.
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 21764873
but how do I update the table? the above query will give me just the view and would not update the records

Thanks
0
 
LVL 3

Expert Comment

by:NIMTUG_Simon
ID: 21764875
Sry was thinking SQL Server

Might still work if not use

DatePart

Usage: DatePart(interval, date)

Interval may be set to:
yyyy for year
q for quarter
m for month
y for day of year
d for day
w for weekday
ww for week
h for hour
n for minute
s for second

Returns: Interval part of date.
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 21764905
whats that? I have no idea how to use the above suggestion
Thanks
0
 
LVL 3

Accepted Solution

by:
NIMTUG_Simon earned 2000 total points
ID: 21764916
ONly got Access 2003.. not sure if later version support calculated fields

You could populate all your dates and then run the following query which will update the other columns

UPDATE Table1 SET Table1.[Day] = Day([Date]), Table1.[Month] = Month([Date]), Table1.[Year] = Year([Date]);
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 21764947
shouldn't it be

update table set month = month(date), day = day(date), year = year(date);

????????????????
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 21764951
ok no worries posted before looking at your second comment. Basically the same thing...I will try it now.
Thanks
0
 
LVL 3

Expert Comment

by:NIMTUG_Simon
ID: 21764961
It doesn't matter about the order and the Table1 prefix is optional. You should alway use [ ] around column names that are the same as in-built Access functions.
0
 
LVL 9

Author Closing Comment

by:syedasimmeesaq
ID: 31466394
thanks
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question