Solved

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

Posted on 2008-06-11
9
205 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 500 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

739 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