473,387 Members | 1,619 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,387 software developers and data experts.

Sql Date To String

1
Produce a list of all employees and their date of hire (HireDate) in the format "ALLEN was hired on the "22nd of Feburary."




emp table


EmpNo Ename Job Mgr HireDate Sal Comm
7369 SMITH CLERK 7902 6/7/1980 800
7499 ALLEN SALESMAN 7698 2/2/1981 1600 300
7521 WARD SALESMAN 7698 2/6/1981 1250 500
7566 JONES MANAGER 7839 4/3/1981 2975

Months Table

Month MonthName
1 January
2 February
3 March
4 April
5 May
6 June




Ordinals Table


DayNumber DayOrdinal
1 1st
2 2nd
3 3rd
4 4th
5 5th
6 6th
7 7th
Feb 22 '08 #1
3 2396
debasisdas
8,127 Expert 4TB
Kindly post what you have tried to get the desired output.
Feb 22 '08 #2
FishVal
2,653 Expert 2GB
Hi, there.

Join the tables:
[emp table] and [Months Table] on Month([emp table].[HireDate])=[Months Table].[Month]
and the resulting dataset with [Ordinals Table] on Day([emp table].[HireDate])=[Ordinals Table].[DayNumber]

From thus obtained dataset retrieve calculated field like the following:
Expand|Select|Wrap|Line Numbers
  1. [emp table].[Ename] & ' was hired on ' & [Ordinals Table].[DayOrdinal] & ' of ' [Months Table].[MonthName]
  2.  
BTW, in Access you may not use [Month Table] at all as soon as Format() function can retrieve month name (either full or 3-letters signature) from date.

Regards.
Fish

P.S. [Ordinals Table] may be omitted too using simple logic like the following
Expand|Select|Wrap|Line Numbers
  1. Day([emp table].[HireDate]) & Nz(Switch(Day([emp table].[HireDate]) Mod 10 = 1, "st", Day([emp table].[HireDate]) Mod 10 = 2, "nd", Day([emp table].[HireDate]) Mod 10 = 3, "rd"), "th")
  2.  
Feb 22 '08 #3
NeoPa
32,556 Expert Mod 16PB
This is a "Homework" question. I am locking it now.

If, by any chance, it is not homework, then it's clearly a lazily and disrespectfully posted question.

Either way, if you want help then state your question clearly and say what you've done to try to resolve it yourself (FAQ - How to Ask a Question). This can now be done in a new (separate) thread.
Feb 23 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
4
by: Robert Scarborough | last post by:
I have a Table in a Typed Dataset which contains a Date field called EventDate. I've ensured that the field is defined as Date as opposed to DateTime in the Typed Dataset. When I generate an...
15
by: Paul J. Ettl | last post by:
Two questions: I use var date1 = new Date(); to get todays date. But how can I get yesterdays date? Furthermore I use
12
by: DC Gringo | last post by:
How can I convert this pubLatest to a date with format "m/d/yyyy"? Dim pubLatest As New Date pubLatest = Me.SqlSelectCommand1.Parameters("@pubLatest").Value -- _____ DC G
2
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
21
by: Darin | last post by:
I have an applicatoin that works 100% perfect when running on a machine setup for English (United States), but when I change it to Spanish (Mexico), the dates start giving me fits. THe reason is...
7
by: creative1 | last post by:
Hello everyone. I am experiencing a strange problem that I can't fix on my own. I think I need expert's suggestions for this. The problem is: I want to print account statement (or any other...
5
Stang02GT
by: Stang02GT | last post by:
I have been asked to validate a date on our web-page so that people cannot enter dates like 14/1/08 or 2/30/06. I have found code that will do exactly what i need it to do, but i am not sure how to...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.