T-SQL (SS2K8) :: Formatting Date Of Birth Using RSA ID Number

Nov 8, 2012

I need creating date of birth using ID number the ouput that im looking is a follows

e.g. RSA ID: 800101 (80 is year, 01 is month and 01 is day) that will be 1980 01 01
e.g. RSA ID: 000101 (00 is year, 01 is month and 01 is day) that will be 2000 01 01

The desired format I need is to take the above and create date of birth with the below format as required by the application used.

01 Jan 1980
01 Jan 2000

View 9 Replies


ADVERTISEMENT

Formatting For A Birth Date Field??

Sep 16, 2006

Hello, I'm new to SQL Server, working for a non-profit computerizing alot of its data.I imported a table of people's names, birth dates, etc. into SS2005from Access, and the birth_date was imported as an Access date/timefield, giving it the datetime datatype in SQL.The column values look like:10/14/1964 12:00:00 AMWhere and how do I learn to specify that all fields like this should bein ISO format of yyyy-mm-dd??Do I have to create a new column and put all the dates into it??Should I just convert the data in queries/views??Use a constraint to format the data??I can redo the Access table if necessary, it is only 300-some rows.I tried BOL but it was not helpful...The end users will likely enter mm/dd/yy or mm/dd/yyyy and it will haveto be stored properly in the database table as column/fieldbirth_date...Thank you, Tom

View 11 Replies View Related

T-SQL (SS2K8) :: Hot To Get Number Of Days For Given Date Range

Sep 15, 2014

--From the rows I want to know how many number of days a person was active for the given date range.

create table [dbo].[personstatus]
(
id int identity(1,1),
name varchar(100),
DateAdded date,
InactivationDate date ) ;
insert into [dbo].[personstatus] values

[Code] ....

--The output I am looking for.
/*
1) FromDt = '2014-01-01' ToDt ='2014-01-30'
KRISS = 7
VDENTI = 7 days

2) FromDt = '2013-01-01' ToDt ='2014-01-01'
KRISS = 1
VDENTI = 1 days

3) FromDt = '2013-01-01' ToDt ='2014-01-01'
KRISS = 0
VDENTI = 1 days

4) FromDt = '2013-01-01' ToDt ='2014-12-31'

KRISS = 8+24+8+21 = 61 Days
VDENTI = 31+24+31+30 = 116 Days
*/

View 9 Replies View Related

How To Get Age From Date Of Birth

May 15, 2002

Hello Everyone,

I have a table containing a column "date of Birth" in char datatype, I need to calculate Age for the person from his or her date of birth. how would I be able to do that?

Any help will be appreciated.

Thanks

View 3 Replies View Related

Selecting Date Of Birth

Jun 14, 2008

I have table with column Date Of Birth its datatype is smalldatetime. Now I was looking for SQL Statement like I will give from date and to date as parameter it should select date of birth occurring between that date and month.

View 5 Replies View Related

Date Of Birth Conversion

Apr 18, 2000

Hello
Can someone help please?
I'm using SQL Server 7 and trying to update a table containing over 250,000 records. I have a character(8) (CHARDOB) field representing dates of birth in the form YYYYMMDD and would like to update my datetime field (DOB) using a simple update command like:-

UPDATE MyTable SET DOB = RIGHT(CHARDOB, 2) + '/' + SUBSTRING(CHARDOB,
5, 2) + '/' + LEFT(CHARDOB, 4)

but get the message:-

Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.

The strange thing is that this works on a small dataset but crashes and burns on larger ones. I have tried different CAST and CONVERT options to transform the data into the correct format. I have tried a stored procedure, DTS transformations and execute SQL task in my DTS package without success.

Any help will be appreciated.
Len

View 4 Replies View Related

Birth Date 1900-01-01 00:00:00.000

Apr 12, 2005

Hi,all,

How to check the default value set up for datetime field? The reason I am asking is my database

field "birthday" is datetime(8), the default value I set to '' already. Everytime my asp program
have empty birthday or invalid birthdate for this field, the system automaticaly set it to

1900-01-01 00:00:00.000

Do you know what happened?

Thanks!
Betty

View 3 Replies View Related

Average Date Of Birth

Jul 8, 2004

Hi, folks.
I have a table with a column Date_of_birth.
I want to evaluate average date_of_birth by grouping on depts.
AVG function doesn't seem to work with datetime col. Plz help.

View 8 Replies View Related

How To Get Date Of Birth And Age In Years?

Mar 27, 2007

I have a table name employee and datetime column named dateofbirth, how can i write a select statement to show their, date of birth and age in years?

This is how i did it, i couldn't finish it, Any feedback would be very thankful.

select name, datebirth, year(dateofbirth)
from employee

View 10 Replies View Related

Get Date Of Birth Query Problem...

Jun 7, 2007

hello
i want to make one SQL Query in that i have problem so please help me
i have three column  ID,Name,DOB
in that i want top 5 name whose Birthday is incomming   days....
 
reply as soon as..
 

View 7 Replies View Related

Trigger To Calculate Age From Date Of Birth

Dec 12, 2003

Here's the problem. I want to insert age in years to a table of children, using a MS SQL trigger to calculate age from Date of Birth (DOB). DOB format is mm/dd/yyyy. The DOB input comes from an ASP Insert statement. I've tried to use DateDiff and a user-defined function to calculate age without any success. Also the trigger needs to account for children of less than 1 year old, could be a 0. Age is integer in the children table. Any help is greatly appreciated. The sooner the better. Even a kick start is better than nothing.

View 11 Replies View Related

Converting Birth Date Format

May 6, 2014

I am trying to convert the birth dated from 19591229 to 12/29/1959 and using below code but its not giving me in that format its printing line 1959-12-29. how do I do this?

bdate=convert(date, p.date_of_birth,101)

View 10 Replies View Related

Creating Birth Date From Day, Month, Year Fields

Nov 14, 2007

I have 3 fields (DOB_YEAR, DOB_MO, DOB_DAY)

They are populated like this (1985, 12, 21)

I would like to take the 3 values of populate one field (BIRTH_DATE) with these combined values to look like this (19851221) BIRTH_DATE is an 8 character field in datetime format.

The code

UPDATE DOB
SET BIRTH_DATE = (dob_year+dob_mo+dob_day)

Returns 6/11/1905 for 1959,11,17

View 5 Replies View Related

Reporting Services :: Formatting A Date Field To Just Show Date Not Minutes?

Jul 6, 2015

A date field in a report returns the date value as:

2015-07-01 13:30:27.000

Is there any way I can script this to appear as:

01 July 2015 (or 01-07-2015 or 01/07/2015)  - basically to cut out the hours, minutes and seconds?

The best I have managed is: CONVERT (varchar(17),DATE,113) AS Date1 but this still leaves me with:

01 July 2015 13:30

View 9 Replies View Related

Number Formatting In SQLSERVER

Feb 14, 2005

say, i have a column in the database that has number values. I want to display these number with comma separators (Eg: if the column values is 1654, then i want to display it as 1,654).

How can i achieve this in my sQL query

View 2 Replies View Related

Phone Number Formatting

Feb 12, 2013

I have a table filled with phone numbers entered in every different way possible

(5551212, 1115551212, 111-555-1212, 111 555 1212, 111-555-1212 ex 1234, 5551212 x1234)

And I would like to pull them from the table using sql 2008 and have the formatting look like this:

(111)555-1212 x1234.

How can I make this happen? Where numbers are missing, I would prefer to leave the area blank, ie 5551212 becomes 555-1212, and 1115551212 becomes (111)555-1212, extension numbers only where they are currently included.

View 14 Replies View Related

Phone Number Formatting

Apr 26, 2007



If I have a string of 10 numbers (with no other characters), what is the best way to format them into a standard phone format: xxx-xxx-xxxx?



I tried numerous variations in the format code and edit expression areas, but no luck.

View 12 Replies View Related

Formatting Number (Urgent)

Oct 10, 2007


Here is what I have
CDec(Sum(Val(Fields!Test1.Value))/(Val(CountRows("Group1"))*SomeNumber)*100%)
This works fine
but the problem is the number can be 25.325641. I only want to get 25 so I did this


Int(Sum(Val(Fields!Test1.Value))/(Val(CountRows("Group1"))*SomeNumber)*100%)

This did the trick but if the number is .255667 it will display 0.

here is what i want:
1-if the number is bigger than 0 i don't want to display the decimals for example:
25.01245 = 25

2-if the number is less than 0. I only want to display 2 decimal places
.256415 = .25

Thanks

View 4 Replies View Related

Number Formatting In A SQL Select Statement

Apr 6, 2005

 
Hi
I'm trying to convert and format integer values in a SQL Server select statement to a string representation of the number formated with ,'s (1000000 becomes 1,000,000 for example).
I've been looking at CAST and CONVERT and think the answers there somewhere. I just don'tseem to be able to work it out.
Anyone out there able to help me please?
Thanks,Keith.

View 4 Replies View Related

Formatting Date SQL Date To Remove Time

May 2, 2008

Hi,I need a way of changing the following SQL statement so that the dates are without the hh:mm:ss tt:"Select DISTINCT([StartDate]) From [Events]"How can this be done?Thanks,Curt.

View 4 Replies View Related

Remove Formatting From Phone Number Column

Jul 9, 2000

I have a column of phone numbers that have formatting such as (xxx)xxx-xxxx,
or xxx.xxx.xxxx or xxx.xxx-xxxx; however, not all phone numbers are formatted in this fashion. I need to remove all characters and only leave behind numeric digits to look like xxxxxxxxxx. I have tried select replace(colname,'-','') from table. This does the trick but does not actually change the values in the column. Any help in accomplishing this would be helpful. Thanks in advance.

Paul

View 1 Replies View Related

Phone Number Formatting - Standardize Information

Sep 23, 2013

SQL query: I am importing data from one source to another. The phone number has 3 variations and I want to standardize the information. I need to remove the "+1" or "1" from the leading characters of the phone number.

example:
13035554444
+13035554444

View 4 Replies View Related

Create Table For Phone Number Formatting?

Jul 15, 2014

I am trying to get my SQL create table to work for my phone number formatting and it is not. When I create the below code, the default is set to 3 numbers only.

CREATE SET TABLE dl_qpt_cqe.contacts, NO FALLBACK ,NO BEFORE JOURNAL,NO AFTER JOURNAL

(contact_id integer not null ,contact varchar(50) , jobtitle varchar(50), dept varchar(50), phone integer format '999-999-9999', phone_ext varchar(10), email varchar(50), constraint pk primary key (contact_id));

Is there some other way I need to format the phone portion so the default is 999-999-9999?

View 1 Replies View Related

Export To Excel - Formatting Number Output

Aug 17, 2006

Hi all,

Once again, SSIS is giving me a 'F.U.N.' time (ask for definition of the F.U.N. acronym another time ).

I
have a relatively simple task - create an excel spreadsheet with 3
columns of data - Id, Description and Sales. ID and Description are
text, sales is int.

So my SP aggregates and creates my resultset
in my OLE DB Source in the Data Flow. It proceeds to the Excel
destination, and that all seems fine. My issue is that the data is
being written as text. Looking at the excel destination in Advanced
editor:
the Excel Destination Input, Input columns are formatted as
I expected: DT_WSTR 8 for the ID, DT_WSTR 100 for the Description and
DT_I4 for the Sales.
Excel Destination Input, External columns refuse to fall in line, though. They are all listed as DT_WSTR 255.

The
target excel spreadsheet is being created from a template file. That
template file has header columns. The target column for the Sales has
the entire column formatted to NUMBER (0 decimals). Yet to now avail.

When
I check the spreadsheet, the column has retained the cell formatting,
and I have a 'I' pop-up to inform me that 'someone' has inserted text
data into the number column (even though the data IS number).

Since
the SP spits out INT, it isn't a case of receiving a text value, imho.
While trying to change the external column data type in the advanced
editor, SSIS is quite happy to let me change the value for the Sales
output to DT_I4, apply, and ok. Then, when I open it immedaitely
aftgerwards, it has reverted to the DT_WSTR's! AArrgh. If is can't
handle it, at least tell me when I try and change it. don't let me
change it, and then revert back without telling me! Grumble grumble...

So - anyone know a way around this?

View 6 Replies View Related

Export To Excel Number Formatting Problem

Jul 4, 2007

Hi,

when i try to export reports to excel number fileds has exported as text !!

I use SQL server with database in US codepage, Reporting Services in english version but excel with Italian codepage settings.

So i must convert the defaul decimal separator from "." to "," within the report generation. This cause that i can't use te cdbl() conversion directly in the report field.

Anyone have sugestion ??



P.S. I can't change the database and excel codepage settings

View 2 Replies View Related

SQL Reporting Services 2005: Formatting A Number

Mar 11, 2008

I know this is very simple, and I've done it before, but now I can't remember how to do it and I keep failing to do it correctly. I want to format a 6 digit number like this: 00-00-00. The number is returned from the database as 6 digits, and I just want to add the dashes.

I tried putting ##-##-## in the Format cell in the properties of the textbox (which I thought worked before) but it's not doing the trick. What am I doing wrong here?

View 4 Replies View Related

SQL Or Visual Web Developer 2005 To Arrange Phone Number Formatting?

Jul 31, 2006

i am trying to build a database that contains a coloumn of phone number but i reallly dont know where and how i will be able to give a specific format for phone numbers.. or anything else any common type of information that may have a format..



Will i use Visual Web Developer or SQL Server Management or whatever else to arrange my phone number coloumn?

View 5 Replies View Related

Date Formatting

Oct 10, 2001

I'm currently getting a date in this format 2001-10-08 10:35:45
(yyyy-mm-dd hh:mm:ss) how would I convert the date to this format
2001-10-08/10:35:45 (yyyy-mm-dd/hh:mm:ss)? The only thing added was the / between the date and time.

Thanks in advance,

Ed

View 2 Replies View Related

Date Formatting

Aug 6, 2004

Hi,

I need to know how i can format the date so that the query results will come out as the format mm/dd/yy hh:mm:ss?

Thanks alot.

View 1 Replies View Related

Date Formatting

Mar 7, 2008

Hello everyone,

I have a date field called book_flag_date of varchar data type.

The values in the table look like this:

3/4/2008 14:32:59

OR

3/4/2008 14:9:0

The issue arises when I am ordering by. I want the value
3/4/2008 14:9:0 to format to 3/4/2008 14:09:00

Thank you very much for your help.

View 7 Replies View Related

Formatting Date In SRS

Sep 27, 2007

I am trying to format a date value as XX/XX/XX when I place a "d" in the format property it formats it as XX/XX/XXXX any ideas on how to change it to XX/XX/XX?

thanks in advance

View 1 Replies View Related

Date Formatting

May 25, 2007

How can I format the current date as yyyy-mm-dd and display it in a text box on the report. The FormatDateTime function only allows certain NamedFormat for the short and long dates but does not satisfy the above requirements. Any ideas?



View 3 Replies View Related

Date Formatting

Feb 13, 2007

My problem is with the paramater format date.

My code and data in SQL are showing the date correctly as dd/mm/yyyy.

When I run report in SSRS a couple of columns show the date mm/dd/yyyy.

The format option in all cells are set to 'd'. There is no difference between the properties on these cells.

The dates themselves seem to go wrong on the date "31/12/4000" and returns them as "12/31/4000".

Any help wqould be appreciated

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved