Showing posts with label yyyy. Show all posts
Showing posts with label yyyy. Show all posts

Tuesday, March 27, 2012

Date query question

Is there a way to run a query or a function that will
return every Saturday of the specified year in mm/dd/yyyy
format?
TIA,
VicUse DATEPART():
-- if you are using default setting
SELECT date FROM table
WHERE DATEPART(dw, date) = 7
"Vic" wrote:
> Is there a way to run a query or a function that will
> return every Saturday of the specified year in mm/dd/yyyy
> format?
> TIA,
> Vic
>|||http://www.aspfaq.com/2519
(Locale-specific format is the job of the presentation layer, btw, and
mm/dd/yyyy is not the best choice.)
--
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Vic" <vduran@.specpro-inc.com> wrote in message
news:02de01c5361c$27813310$a501280a@.phx.gbl...
> Is there a way to run a query or a function that will
> return every Saturday of the specified year in mm/dd/yyyy
> format?
> TIA,
> Vic

Date Problem!

A column in a SQL Server7 DB table has the datatype smalldatetime. All
the records in this column are stored in 'm/d/yyyy' format like
6/15/2005 (15th June 2005), 8/21/2005 (21st August 2005) etc....
Assume that two of the records stores today's date i.e. 9/20/2005 (20th
September 2005). When I execute the following 2 queries in QA
SELECT * FROM tblRecords WHERE Date1='9/20/2005'
SELECT * FROM tblRecords WHERE Date1='20050920'
both the queries retrieve the two records as expected but when I issue
the following query
SELECT * FROM tblRecords WHERE Date1=GETDATE()
no records get retrieved! Why so?
Thanks,
ArpanBecause GETDATE() includes time information. Did you run SELECT GETDATE()
and see that it does not return exactly 20050920?
If you want all rows from today, the most efficient way is probably:
WHERE Date1 >= 0 + DATEDIFF(DAY, 0, GETDATE())
AND Date1 < 1 + DATEDIFF(DAY, 0, GETDATE())
or
DECLARE @.today SMALLDATETIME
SET @.today = 0 + DATEDIFF(DAY, 0, GETDATE())
SELECT
...
WHERE Date1 >= @.today
AND Date1 < (@.today + 1)
(In addition to using an index on date1, this will also allow you to ignore
any time values that might slip into the values in date1.)
"Arpan" <arpan_de@.hotmail.com> wrote in message
news:1127189510.583307.210400@.f14g2000cwb.googlegroups.com...
>A column in a SQL Server7 DB table has the datatype smalldatetime. All
> the records in this column are stored in 'm/d/yyyy' format like
> 6/15/2005 (15th June 2005), 8/21/2005 (21st August 2005) etc....
> Assume that two of the records stores today's date i.e. 9/20/2005 (20th
> September 2005). When I execute the following 2 queries in QA
> SELECT * FROM tblRecords WHERE Date1='9/20/2005'
> SELECT * FROM tblRecords WHERE Date1='20050920'
> both the queries retrieve the two records as expected but when I issue
> the following query
> SELECT * FROM tblRecords WHERE Date1=GETDATE()
> no records get retrieved! Why so?
> Thanks,
> Arpan
>|||Thanks, Aaron, for your help. Good suggestion :-)
Thanks once again,
Regards,
Arpan

Sunday, March 25, 2012

Date Picker in US Format after SP2

Updated SQL 2005 to SP2 and Reporting Services Date Picker now has dates defaulting to US format (MM/DD/YYYY) instead of our previous English-Australian (DD/MM/YYYY). Both the clients and server are set to English Australian regional settings in the O/S and the reports are composed for English Australian language. Reports have correct format in Visual Studio development and re-deploying them had no effect. Everything was fine under SP1 - not sure what is going on. Any ideas?

I have had so much trouble with date fields that I now keep them as text fields in Reporting Services and pass then through to SQL Server as VarChars(). Using three letters for the month (Jan, Feb, Mar etc) is the best way to may sure that SQL Server gets it right. I always set a default in the format "12 Apr 07 13:00" so the use sees what format is required. This means not using the date control but in my applications we time as well as date and the date control doesn't do this anyway.

The problem seems to be that there are many places to set the "country" or "language" etc.

Places that I can think of are:-

1. Control Panel/Regonal and Language Settings.

2. SQL Server using Set Language (or Set DateFormat). I believe that this affects the current session and so must be used in every report query.

3. Intenet Explorer, which is relevant when accessing Report Server.

I am not sure which SP I have but the patch level is 9.1.2153.

|||After doing some more analysis; I have found that if a datetime parameter prompt is placed after two parameters that cascade, then the correct date format (in our case English-Australian DD/MM/YYYY) is used in the Date Picker (probably due to the language settings in the client and report). Otherwise you get the US Date format (MM/DD/YYYY). This means that if you have datetime parameters on their own or even with drop downs, multi-selects etc.. then you could be in for trouble. I could be mistaken but this seems like a bug in SQL 2005 SP2.|||The problem has now been narrowed down to the Reporting Services Sharepoint web parts: rswebparts.cab (v2.0). Reports run with the correct date picker format from the report server but are incorrect if they are run from the SharePoint report viewer web part. I believe these web parts were not updated in SP2 (see http://msdn2.microsoft.com/en-us/library/ms159772.aspx)|||We get this same problem outside of sharepoint after sp2. If you go directly to the reportserver (http://yourserver/reportserver) and navigate to the report you may find the same. This problem has surfaced after the sp2 upgrade - strange thing is that is does not occur if we run the report via report manager - I expect why the sharepoint is showing the problem is because it is making a direct call to the reportserver.

date part of date time

SELECT ltrim(str(datepart(yyyy,getdate()))) +'-'+
replicate('0',2-len(ltrim(str(datepart(mm,getdate())))))+ltrim(str (datepart(mm,getdate())))+'-' +replicate('0',2-len(ltrim(str(datepart(dd,getdate())))))
+ltrim(str(datepart(dd,getdate())))

This is how i am getting datepart of datetime.Is there any other way to get the date and also time seperately..

Thanks.Convert(char(10), getdate(), 120)|||SELECT CONVERT(varchar(10),GetDate(),101), CONVERT(varchar(10),GetDate(),108)|||Beat you by one second, Kaiser! Nyah nyah nyah! Too slow! Ya snooze, ya looze! :p :p :p :p :p|||SELECT CONVERT(varchar(10),GetDate(),101), CONVERT(varchar(10),GetDate(),108)

Where should i know to use 101 and 108 in convert functions.I could get that from BOl...
Can u help me with that.

Thanks and sorry for asking such a silly question.|||I'm sorry i got that myself.

Thank u all.|||I'm sorry i got that myself.

Thank u all.

Congratulations! Because of forum a lot of people became so lazy but not you.|||Beat you by one second, Kaiser! Nyah nyah nyah! Too slow! Ya snooze, ya looze! :p :p :p :p :p

Yeah...see what happens when work gets in the way...

I'm giving out specs over the phone to a noob while I'm doing this...

And this ain't sqlteam...that's 1 minute increments

Damn...[sniped] anyway

And what's with 120?

bleeeeeach...

:D|||And what's with 120?Wah, wah, waaaaah!

120 is just the "junior grade" version of 121, my preferred style!

-PatP|||121? How pretentious. 120 shines in its simplicity and elegance.

Dude, 121 is SOOOOO last version.....

And what's with the varchar, eh?|||Personally I like 126..talk about pretentions...but that's just my mainframe db2 talking...

too bad they lost pos 4-6 of their milliseconds...gotta be the cpu's fault..right?

Figured he wanted 101 though..nice and pretty...

And geez...I need to speak with Karolyn or ms_sql_dba to straighten you out?

:D

I saw you suck'n up blind dude... :)

Varchar...force of habit...

we need more banter in the corral...

http://www.dbforums.com/showthread.php?p=3672844#post3672844|||Don't threaten to sick your dogs on me!

Like I'm gonna be scared of a "126"er...|||Dude, 121 is SOOOOO last version.....Oh, they used to say that about my Leisure Suit and silver tipped cowboy boots too!

-PatP|||Hold on to those. They're coming back.|||Hold on to those. They're coming back.

I hated the 70's..

What do you guys think about this:

http://www.dbforums.com/t996699.html

Wednesday, March 21, 2012

Date Ordering in Charts

I have a chart that has MM/YYYY for tics on the X-axis. The problem is that
January and October are being positioned next to each other...
1/2005...10/2005...2/2005...3/2005
Is there any way to tell the chart to order these by date rather than by
string value?What I've done is create two more columns in your dataset for the date the
mm/yyy stand for (one with the month and one with the year using the month
and year functions). Then group and sort by year and then month. That should
put your October after September instead of January.
"Todd Bright" wrote:
> I have a chart that has MM/YYYY for tics on the X-axis. The problem is that
> January and October are being positioned next to each other...
> 1/2005...10/2005...2/2005...3/2005
> Is there any way to tell the chart to order these by date rather than by
> string value?|||Thanks. I thought RS was doing some kind of ordering, but in fact it was me
just being stupid. I was doing what you mentioned, but I didn't realize that
I was using the same field name to mean different things.
"Tina" wrote:
> What I've done is create two more columns in your dataset for the date the
> mm/yyy stand for (one with the month and one with the year using the month
> and year functions). Then group and sort by year and then month. That should
> put your October after September instead of January.
> "Todd Bright" wrote:
> > I have a chart that has MM/YYYY for tics on the X-axis. The problem is that
> > January and October are being positioned next to each other...
> >
> > 1/2005...10/2005...2/2005...3/2005
> >
> > Is there any way to tell the chart to order these by date rather than by
> > string value?sql

Monday, March 19, 2012

Date insert from VB.net problem

Hey there,

I'm trying to add rows to a table and pass a date value through. I use Format(Date.now, "dd MMM yyyy") however when I check in SQL Server Managment Studio it has swapped the day and month round (e.g. input of "7/9/2006" will be "9/7/2006" on the actual table. Actually the output is 2006-07-09 00:00:00:00.) I've put the full source code below.

Can anyone help with this?

Cheers,

Danny

Imports System.Data

Imports System.Data.SqlClient

Public Class Form1

Dim dtdate As Date

Dim cn As New SqlConnection("server=*********;database=********;USER ID=*********;password=*********")

Dim objCommand As New SqlCommand("", cn)

Dim ws As New wrtRefID.Service

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

dtdate = Now

AddHistory("ActivityID", 1, "AccountID", "AccountName", "ContactName", "Category", Microsoft.VisualBasic.Format(dtdate, "dd MMM yyyy"), 2, "Description", "UserName", Microsoft.VisualBasic.Format(dtdate, "dd MMM yyyy"), "CreateUser", "Notes", "LongNotes")

MessageBox.Show("DONE")

End Sub

Private Sub AddHistory(ByVal ActivityID As String, ByVal Type As Integer, ByVal AccountID As String, _

ByVal AccountName As String, ByVal ContactName As String, ByVal Category As String, ByVal StartDate As Date, _

ByVal Duration As Integer, ByVal Description As String, ByVal UserName As String, _

ByVal CreateDate As Date, ByVal CreateUser As String, ByVal Notes As String, ByVal LongNotes As String)

cn.Open()

objCommand.CommandText = "INSERT INTO HISTORY (HISTORYID, ACTIVITYID, Type, ACCOUNTID, ACCOUNTNAME, CONTACTNAME, " & _

"CATEGORY, STARTDATE, DURATION, DESCRIPTION, USERNAME, CREATEDATE, CREATEUSER, NOTES, LONGNOTES) " & _

"VALUES ('" & ws.MCS2_SLXID("HISTORY") & "', " & "'" & ActivityID & "', '" & Type & "', '" & AccountID & "', '" & AccountName & "', '" & ContactName & _

"', '" & Category & "', '" & StartDate & "', '" & Duration & "', '" & Description & "', '" & UserName & _

"', '" & CreateDate & "', '" & CreateUser & "', '" & Notes & "', '" & LongNotes & "')"

' MessageBox.Show(Format(dtdate, "dd MMM yyyy"))

TextBox1.Text = objCommand.CommandText

objCommand.ExecuteNonQuery()

cn.Close()

End Sub

End Class

Before explaining how to fix the date issue, it's important

to point out that your code may be vulnerable to a damaging

SQL injection attack. If the USER ID here has permission

to do more than insert rows into the table HISTORY, and if

you are not validating input in any way on the client side,

you are in trouble. A malicious user of your application

could enter into LongNotes, for example, a single quote

character followed by any SQL statement he or she wants to

run (like DELETE FROM HISTORY, or much worse, if this session

is opened by the sa account). See this article for more

information: www.sommarskog.se/dynamic_sql.html, or search

the web for "SQL injection."

Please, please, please, always use parameterized queries

or SQL stored procedures (and in the latter case, not

ones that just concatenate user input themselves).

You may be validating input on the client side or using

an account with limited privilege, in which case you should

at least add a comment in your code to note that this code

relies on security to be implemented elsewhere. However,

in my opinion, client-side-only security for this sort

of thing is not sufficient. Just to give one example,

some web sites will enforce what is typed into a form,

but overlook the fact that the form may not be the only

place to supply parameter values - direct specification

in the URL might be, too, and those values won't be

validated.

The best way to pass a date is through a parameterized

query or stored procedure, in which case you don't have

to use any format - you just pass it as a datetime value,

such as a SqlDateTime.

If you must pass your date as a string (and it's unlikely you

must, but it's a quicker, if more reckless, fix from what

you have now than to address the security and use parameters),

use the one date-only string format that SQL Server will

interpret consistently across culture settings: 'yyyymmdd'.

Be sure it's the string 'yyyymmdd', and not the integer yyyymmdd.

The only other safe format is the full datetime format

'YYYY-MM-DDTHH:MM:SS.mmm' (including the T character).

Vulnerable code like this is all too common, and I want

to say something whenever I see it.

Steve Kass

Drew University

http://www.stevekass.com

JediDanny@.discussions.microsoft.com wrote:

> This post has been edited either by the author or a moderator in the

> Microsoft Forums: http://forums.microsoft.com

>

> Hey there,

>

> I'm trying to add rows to a table and pass a date value through. I use

> Format(Date.now, "dd MMM yyyy") however when I check in SQL Server

> Managment Studio it has swapped the day and month round (e.g. input of

> "7/9/2006" will be "9/7/2006" on the actual table. Actually the output

> is 2006-07-09 00:00:00:00.) I've put the full source code below.

>

> Can anyone help with this?

>

> Cheers,

>

> Danny

>

>

>

> Imports System.Data

>

> Imports System.Data.SqlClient

>

> Public Class Form1

>

> Dim dtdate As Date

>

> Dim cn As New SqlConnection("server=*********;database=********;USER

> ID=*********;password=*********")

>

> Dim objCommand As New SqlCommand("", cn)

>

> Dim ws As New wrtRefID.Service

>

> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

> System.EventArgs) Handles Button1.Click

>

> dtdate = Now

>

> AddHistory("ActivityID", 1, "AccountID", "AccountName", "ContactName",

> "Category", Microsoft.VisualBasic.Format(dtdate, "dd MMM yyyy"), 2,

> "Description", "UserName", Microsoft.VisualBasic.Format(dtdate, "dd MMM

> yyyy"), "CreateUser", "Notes", "LongNotes")

>

> MessageBox.Show("DONE")

>

> End Sub

>

> Private Sub AddHistory(ByVal ActivityID As String, ByVal Type As

> Integer, ByVal AccountID As String, _

>

> ByVal AccountName As String, ByVal ContactName As String, ByVal Category

> As String, ByVal StartDate As Date, _

>

> ByVal Duration As Integer, ByVal Description As String, ByVal UserName

> As String, _

>

> ByVal CreateDate As Date, ByVal CreateUser As String, ByVal Notes As

> String, ByVal LongNotes As String)

>

> cn.Open()

>

> objCommand.CommandText = "INSERT INTO HISTORY (HISTORYID, ACTIVITYID,

> Type, ACCOUNTID, ACCOUNTNAME, CONTACTNAME, " & _

>

> "CATEGORY, STARTDATE, DURATION, DESCRIPTION, USERNAME, CREATEDATE,

> CREATEUSER, NOTES, LONGNOTES) " & _

>

> "VALUES ('" & ws.MCS2_SLXID("HISTORY") & "', " & "'" & ActivityID & "',

> '" & Type & "', '" & AccountID & "', '" & AccountName & "', '" &

> ContactName & _

>

> "', '" & Category & "', '" & StartDate & "', '" & Duration & "', '" &

> Description & "', '" & UserName & _

>

> "', '" & CreateDate & "', '" & CreateUser & "', '" & Notes & "', '" &

> LongNotes & "')"

>

> ' MessageBox.Show(Format(dtdate, "dd MMM yyyy"))

>

> TextBox1.Text = objCommand.CommandText

>

> objCommand.ExecuteNonQuery()

>

> cn.Close()

>

> End Sub

>

> End Class

>

>

|||

It's doing exactly what you told it to do.

Your format string is saying day + month + year (ddMMyyyy) This is not wrong. You're reading it wrong.

If you want it to say month + day + year then write the format string thataway (MMddyyyy)

Adamus

|||

NNTP User wrote:

Before explaining how to fix the date issue, it's important

to point out that your code may be vulnerable to a damaging

SQL injection attack. If the USER ID here has permission

to do more than insert rows into the table HISTORY, and if

you are not validating input in any way on the client side,

you are in trouble. A malicious user of your application

could enter into LongNotes, for example, a single quote

character followed by any SQL statement he or she wants to

run (like DELETE FROM HISTORY, or much worse, if this session

is opened by the sa account). See this article for more

information: www.sommarskog.se/dynamic_sql.html, or search

the web for "SQL injection."

Please, please, please, always use parameterized queries

or SQL stored procedures (and in the latter case, not

ones that just concatenate user input themselves).

You may be validating input on the client side or using

an account with limited privilege, in which case you should

at least add a comment in your code to note that this code

relies on security to be implemented elsewhere. However,

in my opinion, client-side-only security for this sort

of thing is not sufficient. Just to give one example,

some web sites will enforce what is typed into a form,

but overlook the fact that the form may not be the only

place to supply parameter values - direct specification

in the URL might be, too, and those values won't be

validated.

The best way to pass a date is through a parameterized

query or stored procedure, in which case you don't have

to use any format - you just pass it as a datetime value,

such as a SqlDateTime.

If you must pass your date as a string (and it's unlikely you

must, but it's a quicker, if more reckless, fix from what

you have now than to address the security and use parameters),

use the one date-only string format that SQL Server will

interpret consistently across culture settings: 'yyyymmdd'.

Be sure it's the string 'yyyymmdd', and not the integer yyyymmdd.

The only other safe format is the full datetime format

'YYYY-MM-DDTHH:MM:SS.mmm' (including the T character).

Vulnerable code like this is all too common, and I want

to say something whenever I see it.

Steve Kass

Drew University

http://www.stevekass.com

JediDanny@.discussions.microsoft.com wrote:

> This post has been edited either by the author or a moderator in the

> Microsoft Forums: http://forums.microsoft.com

>

> Hey there,

>

> I'm trying to add rows to a table and pass a date value through. I use

> Format(Date.now, "dd MMM yyyy") however when I check in SQL Server

> Managment Studio it has swapped the day and month round (e.g. input of

> "7/9/2006" will be "9/7/2006" on the actual table. Actually the output

> is 2006-07-09 00:00:00:00.) I've put the full source code below.

>

> Can anyone help with this?

>

> Cheers,

>

> Danny

>

>

>

> Imports System.Data

>

> Imports System.Data.SqlClient

>

> Public Class Form1

>

> Dim dtdate As Date

>

> Dim cn As New SqlConnection("server=*********;database=********;USER

> ID=*********;password=*********")

>

> Dim objCommand As New SqlCommand("", cn)

>

> Dim ws As New wrtRefID.Service

>

> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

> System.EventArgs) Handles Button1.Click

>

> dtdate = Now

>

> AddHistory("ActivityID", 1, "AccountID", "AccountName", "ContactName",

> "Category", Microsoft.VisualBasic.Format(dtdate, "dd MMM yyyy"), 2,

> "Description", "UserName", Microsoft.VisualBasic.Format(dtdate, "dd MMM

> yyyy"), "CreateUser", "Notes", "LongNotes")

>

> MessageBox.Show("DONE")

>

> End Sub

>

> Private Sub AddHistory(ByVal ActivityID As String, ByVal Type As

> Integer, ByVal AccountID As String, _

>

> ByVal AccountName As String, ByVal ContactName As String, ByVal Category

> As String, ByVal StartDate As Date, _

>

> ByVal Duration As Integer, ByVal Description As String, ByVal UserName

> As String, _

>

> ByVal CreateDate As Date, ByVal CreateUser As String, ByVal Notes As

> String, ByVal LongNotes As String)

>

> cn.Open()

>

> objCommand.CommandText = "INSERT INTO HISTORY (HISTORYID, ACTIVITYID,

> Type, ACCOUNTID, ACCOUNTNAME, CONTACTNAME, " & _

>

> "CATEGORY, STARTDATE, DURATION, DESCRIPTION, USERNAME, CREATEDATE,

> CREATEUSER, NOTES, LONGNOTES) " & _

>

> "VALUES ('" & ws.MCS2_SLXID("HISTORY") & "', " & "'" & ActivityID & "',

> '" & Type & "', '" & AccountID & "', '" & AccountName & "', '" &

> ContactName & _

>

> "', '" & Category & "', '" & StartDate & "', '" & Duration & "', '" &

> Description & "', '" & UserName & _

>

> "', '" & CreateDate & "', '" & CreateUser & "', '" & Notes & "', '" &

> LongNotes & "')"

>

> ' MessageBox.Show(Format(dtdate, "dd MMM yyyy"))

>

> TextBox1.Text = objCommand.CommandText

>

> objCommand.ExecuteNonQuery()

>

> cn.Close()

>

> End Sub

>

> End Class

>

>

WTF? lol|||

NNTP User wrote:

Before explaining how to fix the date issue, it's important

to point out that your code may be vulnerable to a damaging

SQL injection attack. If the USER ID here has permission

to do more than insert rows into the table HISTORY, and if

you are not validating input in any way on the client side,

you are in trouble. A malicious user of your application

could enter into LongNotes, for example, a single quote

character followed by any SQL statement he or she wants to

run (like DELETE FROM HISTORY, or much worse, if this session

is opened by the sa account). See this article for more

information: www.sommarskog.se/dynamic_sql.html, or search

the web for "SQL injection."

Please, please, please, always use parameterized queries

or SQL stored procedures (and in the latter case, not

ones that just concatenate user input themselves).

You may be validating input on the client side or using

an account with limited privilege, in which case you should

at least add a comment in your code to note that this code

relies on security to be implemented elsewhere. However,

in my opinion, client-side-only security for this sort

of thing is not sufficient. Just to give one example,

some web sites will enforce what is typed into a form,

but overlook the fact that the form may not be the only

place to supply parameter values - direct specification

in the URL might be, too, and those values won't be

validated.

The best way to pass a date is through a parameterized

query or stored procedure, in which case you don't have

to use any format - you just pass it as a datetime value,

such as a SqlDateTime.

If you must pass your date as a string (and it's unlikely you

must, but it's a quicker, if more reckless, fix from what

you have now than to address the security and use parameters),

use the one date-only string format that SQL Server will

interpret consistently across culture settings: 'yyyymmdd'.

Be sure it's the string 'yyyymmdd', and not the integer yyyymmdd.

The only other safe format is the full datetime format

'YYYY-MM-DDTHH:MM:SS.mmm' (including the T character).

Vulnerable code like this is all too common, and I want

to say something whenever I see it.

Steve Kass

Drew University

http://www.stevekass.com

JediDanny@.discussions.microsoft.com wrote:

> This post has been edited either by the author or a moderator in the

> Microsoft Forums: http://forums.microsoft.com

>

> Hey there,

>

> I'm trying to add rows to a table and pass a date value through. I use

> Format(Date.now, "dd MMM yyyy") however when I check in SQL Server

> Managment Studio it has swapped the day and month round (e.g. input of

> "7/9/2006" will be "9/7/2006" on the actual table. Actually the output

> is 2006-07-09 00:00:00:00.) I've put the full source code below.

>

> Can anyone help with this?

>

> Cheers,

>

> Danny

>

>

>

> Imports System.Data

>

> Imports System.Data.SqlClient

>

> Public Class Form1

>

> Dim dtdate As Date

>

> Dim cn As New SqlConnection("server=*********;database=********;USER

> ID=*********;password=*********")

>

> Dim objCommand As New SqlCommand("", cn)

>

> Dim ws As New wrtRefID.Service

>

> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

> System.EventArgs) Handles Button1.Click

>

> dtdate = Now

>

> AddHistory("ActivityID", 1, "AccountID", "AccountName", "ContactName",

> "Category", Microsoft.VisualBasic.Format(dtdate, "dd MMM yyyy"), 2,

> "Description", "UserName", Microsoft.VisualBasic.Format(dtdate, "dd MMM

> yyyy"), "CreateUser", "Notes", "LongNotes")

>

> MessageBox.Show("DONE")

>

> End Sub

>

> Private Sub AddHistory(ByVal ActivityID As String, ByVal Type As

> Integer, ByVal AccountID As String, _

>

> ByVal AccountName As String, ByVal ContactName As String, ByVal Category

> As String, ByVal StartDate As Date, _

>

> ByVal Duration As Integer, ByVal Description As String, ByVal UserName

> As String, _

>

> ByVal CreateDate As Date, ByVal CreateUser As String, ByVal Notes As

> String, ByVal LongNotes As String)

>

> cn.Open()

>

> objCommand.CommandText = "INSERT INTO HISTORY (HISTORYID, ACTIVITYID,

> Type, ACCOUNTID, ACCOUNTNAME, CONTACTNAME, " & _

>

> "CATEGORY, STARTDATE, DURATION, DESCRIPTION, USERNAME, CREATEDATE,

> CREATEUSER, NOTES, LONGNOTES) " & _

>

> "VALUES ('" & ws.MCS2_SLXID("HISTORY") & "', " & "'" & ActivityID & "',

> '" & Type & "', '" & AccountID & "', '" & AccountName & "', '" &

> ContactName & _

>

> "', '" & Category & "', '" & StartDate & "', '" & Duration & "', '" &

> Description & "', '" & UserName & _

>

> "', '" & CreateDate & "', '" & CreateUser & "', '" & Notes & "', '" &

> LongNotes & "')"

>

> ' MessageBox.Show(Format(dtdate, "dd MMM yyyy"))

>

> TextBox1.Text = objCommand.CommandText

>

> objCommand.ExecuteNonQuery()

>

> cn.Close()

>

> End Sub

>

> End Class

>

>

Gotta lay off the crackpipe Steve.

date in Calander is in incorrect format

Hi this is driving me completely mad.
UK based so we want the calendar parameter to display the date format as
dd/MM/yyyy rather than MM/dd/YYYY.
I'm using SQL RS 2005 on a Windows 2003 sp1 box.
I've used regedit to look at all the user account international settings,
all of which are set to UK.
If i log on to the box and run the report the server the date format in the
calendar parameter display correctly.
Same account on annother machine displays it in the US format.
I've also checked my regional settings on the other machine and it shows UK.
Where else is it going to pick up the US format from?What is the report's default format value for the date that is displayed on
the report?
=-Chris
"Namshub" <Ricchard.Pullen@.Southend.nhs.uk.RemoveMyspam> wrote in message
news:%23J6J5MUDHHA.4832@.TK2MSFTNGP06.phx.gbl...
> Hi this is driving me completely mad.
> UK based so we want the calendar parameter to display the date format as
> dd/MM/yyyy rather than MM/dd/YYYY.
> I'm using SQL RS 2005 on a Windows 2003 sp1 box.
> I've used regedit to look at all the user account international settings,
> all of which are set to UK.
> If i log on to the box and run the report the server the date format in
> the calendar parameter display correctly.
> Same account on annother machine displays it in the US format.
> I've also checked my regional settings on the other machine and it shows
> UK.
>
> Where else is it going to pick up the US format from?
>|||The report format is fine as I set the documents local to UK, and all dates
display correctly without specific formating. It is just the Parameterised
Calendar combo (which I use for a start and end date filtering)
"Chris Conner" <Chris.Conner@.NOSPAMPolarisLibrary.com> wrote in message
news:e%23xrIkaDHHA.4024@.TK2MSFTNGP04.phx.gbl...
> What is the report's default format value for the date that is displayed
> on the report?
> =-Chris
> "Namshub" <Ricchard.Pullen@.Southend.nhs.uk.RemoveMyspam> wrote in message
> news:%23J6J5MUDHHA.4832@.TK2MSFTNGP06.phx.gbl...
>> Hi this is driving me completely mad.
>> UK based so we want the calendar parameter to display the date format as
>> dd/MM/yyyy rather than MM/dd/YYYY.
>> I'm using SQL RS 2005 on a Windows 2003 sp1 box.
>> I've used regedit to look at all the user account international
>> settings, all of which are set to UK.
>> If i log on to the box and run the report the server the date format in
>> the calendar parameter display correctly.
>> Same account on annother machine displays it in the US format.
>> I've also checked my regional settings on the other machine and it shows
>> UK.
>>
>> Where else is it going to pick up the US format from?
>

Sunday, March 11, 2012

Date formatting very flakey

We have a couple of dates displayed on our report.
The first comes from a string in our code, and I have a format
of 'mm/dd/yyyy'
The second comes from Globals!ExecutionTime, and I have a format of 'd'
These both display the way we want (which is with leading zeros) when
we stream the report to Excel.
But when we use the ReportViewer control, or when we stream the report
to html, we get strange stuff, like
00/03/2005 (s/b 09/03/2005) in the first case,
and
42/20/2005 (s/b 02/20/2006) in the second case. (Particularly
perturbing, since this is an RS global)Does using a capital m work properly? The lowercase m is for minute.
Check to see if "MM/dd/yyyy" works properly. I haven't had a problem
with the formatting and would be inetersted if this solved your
problem.
Regards,
Dan|||Ahh..much better, thanks!

Date Formatting

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

You need to change the report properties language setting to: English (United Kingdom). It defaults to English(United States)

Date Formats

Hi all,
In our whole system (Sql server, forms applications etc) I have configured
our date formats to be dd/mm/yyyy, as this is the easiest for my users. My
problem is that Reporting services only respond to the format mm/dd/yyyy
... How can I configure reporting services to only use the format
dd/mm/yyyy?
Thanks alot in advance
RThere is a language property for the report and a textbox. You can for
example select English (United Kingdom), and the date will display as
dd/mm/yy. There is also an International Settings option in Tools,Options of
the development enviromnent.
The report property setting overrides the global setting, and the textbox
property overrides the report property.
The language property can also be left as Default on the report or textbox.
If left as Default, the more global settings takes effect.
Finally, you can use custom expressions such as
=Format(Fields!MyDateField.Value, "dd/MMM/yy")
HTH
Charles Kangai, MCT, MCDBA
"Rudi Groenewald" wrote:
> Hi all,
> In our whole system (Sql server, forms applications etc) I have configured
> our date formats to be dd/mm/yyyy, as this is the easiest for my users. My
> problem is that Reporting services only respond to the format mm/dd/yyyy
> .... How can I configure reporting services to only use the format
> dd/mm/yyyy?
> Thanks alot in advance
> R
>
>|||Hi
I'm using the product in the UK so the international settings are important.
On the Tools, Options route I only get the choice of 'English (United States)
or 'Same as Microsoft Office (Language Neutral)'. I'm not sure if this is
because I'm an MSDN subscriber or not.
I'm not keen on having to manually change the properties in every field on a
report so I can get dates, currencies etc in the right format. Is there a way
of using the machine regional settings as is done by most other products?
If this is just a problem because I'm using an MSDN version then I'll have
to bite the bullet and get rid of my MSDN developer subscription.
Cheers
Dave
"Charles Kangai" wrote:
> There is a language property for the report and a textbox. You can for
> example select English (United Kingdom), and the date will display as
> dd/mm/yy. There is also an International Settings option in Tools,Options of
> the development enviromnent.
> The report property setting overrides the global setting, and the textbox
> property overrides the report property.
> The language property can also be left as Default on the report or textbox.
> If left as Default, the more global settings takes effect.
> Finally, you can use custom expressions such as
> =Format(Fields!MyDateField.Value, "dd/MMM/yy")
> HTH
> Charles Kangai, MCT, MCDBA
> "Rudi Groenewald" wrote:
> > Hi all,
> >
> > In our whole system (Sql server, forms applications etc) I have configured
> > our date formats to be dd/mm/yyyy, as this is the easiest for my users. My
> > problem is that Reporting services only respond to the format mm/dd/yyyy
> > .... How can I configure reporting services to only use the format
> > dd/mm/yyyy?
> >
> > Thanks alot in advance
> >
> > R
> >
> >
> >|||There is no need to change the Language property of every field. Just change
it for the report. The Language property of the report takes effect unless
you change it at textbox level. Textbox setting overrides Report setting.
You are obviously aware of the Microsoft Office language setting in Tools,
Options. Have you tried using it and seeing whether new reports automatically
take the language that is set in Microsoft office? I am also in the UK, but
unfortunately have the US language installed as I am working for a US company.
Failing that, use the Report language property and not have to change it for
each textbox.
Cheers
Charles Kangai, MCT, MCDBA
"Dave Phillimore" wrote:
> Hi
> I'm using the product in the UK so the international settings are important.
> On the Tools, Options route I only get the choice of 'English (United States)
> or 'Same as Microsoft Office (Language Neutral)'. I'm not sure if this is
> because I'm an MSDN subscriber or not.
> I'm not keen on having to manually change the properties in every field on a
> report so I can get dates, currencies etc in the right format. Is there a way
> of using the machine regional settings as is done by most other products?
> If this is just a problem because I'm using an MSDN version then I'll have
> to bite the bullet and get rid of my MSDN developer subscription.
> Cheers
> Dave
> "Charles Kangai" wrote:
> > There is a language property for the report and a textbox. You can for
> > example select English (United Kingdom), and the date will display as
> > dd/mm/yy. There is also an International Settings option in Tools,Options of
> > the development enviromnent.
> >
> > The report property setting overrides the global setting, and the textbox
> > property overrides the report property.
> >
> > The language property can also be left as Default on the report or textbox.
> > If left as Default, the more global settings takes effect.
> >
> > Finally, you can use custom expressions such as
> > =Format(Fields!MyDateField.Value, "dd/MMM/yy")
> >
> > HTH
> >
> > Charles Kangai, MCT, MCDBA
> >
> > "Rudi Groenewald" wrote:
> >
> > > Hi all,
> > >
> > > In our whole system (Sql server, forms applications etc) I have configured
> > > our date formats to be dd/mm/yyyy, as this is the easiest for my users. My
> > > problem is that Reporting services only respond to the format mm/dd/yyyy
> > > .... How can I configure reporting services to only use the format
> > > dd/mm/yyyy?
> > >
> > > Thanks alot in advance
> > >
> > > R
> > >
> > >
> > >|||Hello All,
This message appears to be related to a problem I have with date formats,
however the solution given only makes the report display in one format or
another. My problem is that I have users all over the world that want to
display the same report. I would like to have the same report display for
them all without having to specify one language over another and have it
automatically handled by Reporting Services. Does anyone know of a way to do
this? or am I stuck creating multiple reports, one for standard date format
and the other for each different format?
Thanks
"Charles Kangai" wrote:
> There is no need to change the Language property of every field. Just change
> it for the report. The Language property of the report takes effect unless
> you change it at textbox level. Textbox setting overrides Report setting.
> You are obviously aware of the Microsoft Office language setting in Tools,
> Options. Have you tried using it and seeing whether new reports automatically
> take the language that is set in Microsoft office? I am also in the UK, but
> unfortunately have the US language installed as I am working for a US company.
> Failing that, use the Report language property and not have to change it for
> each textbox.
> Cheers
> Charles Kangai, MCT, MCDBA
> "Dave Phillimore" wrote:
> > Hi
> >
> > I'm using the product in the UK so the international settings are important.
> > On the Tools, Options route I only get the choice of 'English (United States)
> > or 'Same as Microsoft Office (Language Neutral)'. I'm not sure if this is
> > because I'm an MSDN subscriber or not.
> >
> > I'm not keen on having to manually change the properties in every field on a
> > report so I can get dates, currencies etc in the right format. Is there a way
> > of using the machine regional settings as is done by most other products?
> >
> > If this is just a problem because I'm using an MSDN version then I'll have
> > to bite the bullet and get rid of my MSDN developer subscription.
> >
> > Cheers
> > Dave
> >
> > "Charles Kangai" wrote:
> >
> > > There is a language property for the report and a textbox. You can for
> > > example select English (United Kingdom), and the date will display as
> > > dd/mm/yy. There is also an International Settings option in Tools,Options of
> > > the development enviromnent.
> > >
> > > The report property setting overrides the global setting, and the textbox
> > > property overrides the report property.
> > >
> > > The language property can also be left as Default on the report or textbox.
> > > If left as Default, the more global settings takes effect.
> > >
> > > Finally, you can use custom expressions such as
> > > =Format(Fields!MyDateField.Value, "dd/MMM/yy")
> > >
> > > HTH
> > >
> > > Charles Kangai, MCT, MCDBA
> > >
> > > "Rudi Groenewald" wrote:
> > >
> > > > Hi all,
> > > >
> > > > In our whole system (Sql server, forms applications etc) I have configured
> > > > our date formats to be dd/mm/yyyy, as this is the easiest for my users. My
> > > > problem is that Reporting services only respond to the format mm/dd/yyyy
> > > > .... How can I configure reporting services to only use the format
> > > > dd/mm/yyyy?
> > > >
> > > > Thanks alot in advance
> > > >
> > > > R
> > > >
> > > >
> > > >|||Apologies in advance if I have not properly understood. If you want the users
to see exactly the same thing, then you hard-code the date format in the
Format property of the field, e.g. dd-MMM-yyyy. If you want their Regional
Settings to be used, you can just enter a single letter "d" in the Format
property or "D". "d" stands for short date format as indicated in Regional
Settings; "D" stands for long date.
As far as I can see you can do anything you want: have the date display
according to the user's locale, or have a fixed display irrespective of
user's locale.
Charles Kangai, MCT, MCDBA
"Support Mechanic" wrote:
> Hello All,
> This message appears to be related to a problem I have with date formats,
> however the solution given only makes the report display in one format or
> another. My problem is that I have users all over the world that want to
> display the same report. I would like to have the same report display for
> them all without having to specify one language over another and have it
> automatically handled by Reporting Services. Does anyone know of a way to do
> this? or am I stuck creating multiple reports, one for standard date format
> and the other for each different format?
> Thanks
>
> "Charles Kangai" wrote:
> > There is no need to change the Language property of every field. Just change
> > it for the report. The Language property of the report takes effect unless
> > you change it at textbox level. Textbox setting overrides Report setting.
> >
> > You are obviously aware of the Microsoft Office language setting in Tools,
> > Options. Have you tried using it and seeing whether new reports automatically
> > take the language that is set in Microsoft office? I am also in the UK, but
> > unfortunately have the US language installed as I am working for a US company.
> >
> > Failing that, use the Report language property and not have to change it for
> > each textbox.
> >
> > Cheers
> >
> > Charles Kangai, MCT, MCDBA
> >
> > "Dave Phillimore" wrote:
> >
> > > Hi
> > >
> > > I'm using the product in the UK so the international settings are important.
> > > On the Tools, Options route I only get the choice of 'English (United States)
> > > or 'Same as Microsoft Office (Language Neutral)'. I'm not sure if this is
> > > because I'm an MSDN subscriber or not.
> > >
> > > I'm not keen on having to manually change the properties in every field on a
> > > report so I can get dates, currencies etc in the right format. Is there a way
> > > of using the machine regional settings as is done by most other products?
> > >
> > > If this is just a problem because I'm using an MSDN version then I'll have
> > > to bite the bullet and get rid of my MSDN developer subscription.
> > >
> > > Cheers
> > > Dave
> > >
> > > "Charles Kangai" wrote:
> > >
> > > > There is a language property for the report and a textbox. You can for
> > > > example select English (United Kingdom), and the date will display as
> > > > dd/mm/yy. There is also an International Settings option in Tools,Options of
> > > > the development enviromnent.
> > > >
> > > > The report property setting overrides the global setting, and the textbox
> > > > property overrides the report property.
> > > >
> > > > The language property can also be left as Default on the report or textbox.
> > > > If left as Default, the more global settings takes effect.
> > > >
> > > > Finally, you can use custom expressions such as
> > > > =Format(Fields!MyDateField.Value, "dd/MMM/yy")
> > > >
> > > > HTH
> > > >
> > > > Charles Kangai, MCT, MCDBA
> > > >
> > > > "Rudi Groenewald" wrote:
> > > >
> > > > > Hi all,
> > > > >
> > > > > In our whole system (Sql server, forms applications etc) I have configured
> > > > > our date formats to be dd/mm/yyyy, as this is the easiest for my users. My
> > > > > problem is that Reporting services only respond to the format mm/dd/yyyy
> > > > > .... How can I configure reporting services to only use the format
> > > > > dd/mm/yyyy?
> > > > >
> > > > > Thanks alot in advance
> > > > >
> > > > > R
> > > > >
> > > > >
> > > > >|||question sort of related, how would i format the date on a parameter so that
when it is entered "1/1/2005" or "01/01/2005" that it will print January 1,
2005.
thanks in advance
"Rudi Groenewald" wrote:
> Hi all,
> In our whole system (Sql server, forms applications etc) I have configured
> our date formats to be dd/mm/yyyy, as this is the easiest for my users. My
> problem is that Reporting services only respond to the format mm/dd/yyyy
> .... How can I configure reporting services to only use the format
> dd/mm/yyyy?
> Thanks alot in advance
> R
>
>|||Hi,
=Format(DateValue,"MMMM d, yyyy")
HTH,
Eric

Thursday, March 8, 2012

Date Formate in SQL2005 Reporting

Hi,

iam using a datepicker to pass the parameter "From Date" the datepicker date formate ismm/dd/yyyy but i want to change dis todd/mm/yyyyformate.

wat to change to get my requeriment.

Thxs in advance.

HI

Try this in c#

DateTime datetime = new DateTime();
datetime = DateTime.Parse(month.ToString());
string[] monthname = datetime.GetDateTimeFormats();
date= monthname[6].toString();

|||

Thxs karthikeyan for ur quick reply, but i asked for SSRS

|||

Use dd/MM/yyyy as the format in the Field. Make sure ds and ys are lowercase, Ms are uppercase.

|||

This should give you a good start in using custom expressions in SSRS. It may be C#, but it is still SSRS.

http://msdn2.microsoft.com/en-us/library/ms155798.aspx

|||

if your input parameters to the report go through a stored procedure, then you can check the dates and cobnvert them into any format or transpose them as necessary inside the sql server stored procedure using datepart() and datename() functions.

|||

actually i used the datepicker in the report.....iam displaying this parameter in the report like "Employess from this date to this" but the datepicker date formate is "MM/dd/YYYY"

i want to change this to "dd/mm/yyyy"...i have 2 write code in da report.

Thxs.

Date Format?

Hi all,
Can i insert a date into SQLServer using this format 10072005? (mm/dd/yyyy)
Can i reference data in a search (WHERE) using this format?
IE: WHERE startdt >=01011753 AND enddt <= 10072005
In otherwords a date that doesn't include any separators?
Is this a bad idea?
Cheers,
AdamAdam,
Prefer to use this format:
'20051006' --October 6, 2005
HTH
Jerry
PS - Thanks again Hugo ;-)
"Adam Knight" <adam@.pertrain.com.au> wrote in message
news:OKK18ssyFHA.1264@.tk2msftngp13.phx.gbl...
> Hi all,
> Can i insert a date into SQLServer using this format 10072005?
> (mm/dd/yyyy)
> Can i reference data in a search (WHERE) using this format?
> IE: WHERE startdt >=01011753 AND enddt <= 10072005
> In otherwords a date that doesn't include any separators?
> Is this a bad idea?
> Cheers,
> Adam
>|||Yes, it is a bad idea. Please check http://www.karaszi.com/SQLServer/in...ime
.asp first and
post back if further questions.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Adam Knight" <adam@.pertrain.com.au> wrote in message news:OKK18ssyFHA.1264@.tk2msftngp13.ph
x.gbl...
> Hi all,
> Can i insert a date into SQLServer using this format 10072005? (mm/dd/yyyy
)
> Can i reference data in a search (WHERE) using this format?
> IE: WHERE startdt >=01011753 AND enddt <= 10072005
> In otherwords a date that doesn't include any separators?
> Is this a bad idea?
> Cheers,
> Adam
>

Date format: mm/dd/yyyy does not work

I have a date field I am trying to format so it does not show the minutes,sec's. Seems the obvious way to do this would be to put mm/dd/yyyy in the format property. I tried this and the day and year seem to work, but the month is not showing month. rather it appears to be showing minute. Does month use a different letter?

Hello,

Try this instead for your format:

MM/dd/yyyy

Hope this helps.

Jarret

|||

If your goal is only to remove the minutes, seconds, etc. then you could use this:

Left(yourdatefield, 11) which will display Jul 20, 2007

or for the mm/dd/yyyy format use this:

Convert(char(50), yourdatefield, 103) which will display 07/20/2007

|||( Isn't the correct format for MM/DD/YYYY 101 instead of 103? Isn't 103 the format for DD/MM/YYYY? )|||For the format field, you don't put a format mask.

What you want to use for a date like that is just 'd'.

There are some format codes (I don't know what they are based on) that determine how things get presented in various cases. You don't even have to know them. In the Visual Studio interface, right-click the textbox you want to manipulate and view the properties (not the properties tab(?)), view the Format tab, and look for the little button next to the 'Format code' textbox with the ellipsis. It gives you most of the options you are going to need.|||Looks like you're all right. I ended up using MM/dd/yyy. Who knew it would be case sensative. :-p

thanks all
|||

Quite correct Kent. Thanks for catching my typo.

|||

The solution:

=Format(cdate(Fields!Dias.Value),"MM-dd-yyyy")

Helped?

Regards!!!

|||

As you have noticed already, the M must be in capital letters:

M

Represents the month as a number from 1 through 12. A single-digit month is formatted without a leading zero. For more information about using a single format specifier, see Using Single Custom Format Specifiers.

MM

Represents the month as a number from 01 through 12. A single-digit month is formatted with a leading zero.

MMM

Represents the abbreviated name of the month as defined in the current System.Globalization.DateTimeFormatInfo.AbbreviatedMonthNames property.

MMMM

Represents the full name of the month as defined in the current System.Globalization.DateTimeFormatInfo.MonthNames property.

small m is used for minute. Read more on books online: http://msdn2.microsoft.com/en-us/library/8kb3ddd4.aspx.

|||

Hii i have given you choices which one you want you can use that format.

1)This is the expression for the date-monthname-year

Use this and let me know

=Day(Parameters!time.Value)& "th-" & MonthName(Month(Parameters!time.Value))& "-" &

Year(Parameters!time.Value)


2)Expression to get date as 11-Feb-2007 (3 characters of month)

=Day(Fields!Date.Value)& "-" & Left(MonthName(Month(Fields!Date.Value)),3)& "-" &

Year(Fields!Date.Value)


4) Expression to get the date as well as the time with format as h:mmTongue Tieds

="M/dd/yyyy" & " " & "h:mmTongue Tieds tt"

Hope this works fine.

Thanks

Mahasweta

|||

Hii i have given you choices which one you want you can use that format.

1)This is the expression for the date-monthname-year

Use this and let me know

=Day(Parameters!time.Value)& "th-" & MonthName(Month(Parameters!time.Value))& "-" &

Year(Parameters!time.Value)


2)Expression to get date as 11-Feb-2007 (3 characters of month)

=Day(Fields!Date.Value)& "-" & Left(MonthName(Month(Fields!Date.Value)),3)& "-" &

Year(Fields!Date.Value)


4) Expression to get the date as well as the time with format as h:mmTongue Tieds AM/PM

=Format(datefield,"M/dd/yyyy" & " " & "h:mmTongue Tieds tt")

Hope this works fine.

Thanks

Mahasweta

|||

>>Who knew it would be case sensative

It's case-sensitive (M for Month) because "m" stands for "minutes" in the formatting string I think <g>.

Who knew that an accident of English would be so annoying <g>.

>L<

Date Format settings problem

We have set of (200 over) reports with date-formats selected as default date-format as in windows format - dd/MM/yyyy.

Reports are viewed through the viewer (CR version 9) on IE.

We install CR on a different machine which had a date format of MM/dd/yyyy and then realised after looking into the application that the reports were displaying the formats as what is in the control panel settings.

Though we change the settings and the reports when viewed through the designor is correctly displaying the format as expected but that does not seem to be the case when viewed through the viewer on IE.

But once you open one of the reports force a change and save back the settings for each date-columns it shows correctly even in the viewer.

We uninstalled CR (deleted registry entries in hkey_local_machine\software\ and deleted relevant folders) and re-installed back CR only to see no change.

Any ideas what this would be causing this problem?
Any help appreciated !

Regards,
Kaushik.Here is the solution
Create one formula in each report as 'DateFormat'
Edit formula write there 1

Now

Steps
1) Select DateField in your report - > Right Click -> CustomeStyile -> Customise -> Goto Order Frame click formula there - > insert your 'DateFormat' formula there.

Save the report.
Now it will work

2) Through Program pass formula field values
for DateFormat as 1 or 2 or 3

You will get Date in respective format.
Still you have problem ask me.

Thanks
Vilas

Date format reset

Hi,
I have a date field in a dataset that is bringing back UK formatted dates
(dd/MM/yyyy) from a UK configured SQL Server on a UK configured server. In RS
the preview displays these dates, again as UK - everything is fine so far...
My problem is when I run the report the dates are output in US format
(MM/dd/yyyy). Even if I set the textbox's format to be the correct style
date, the values are always US style.
Any help much appreciated.
AlIf there is no language information set on the text box, the language
of the report is used. If the language of the report is not set, the
language of the Web browser is used. If the language of the Web browser
is not set, the language of the operating system of the report server
is used. For example, if you set a specific language on a text box that
displays date information, then that text box is always displayed with
the date format for that language even if the report, Web browser or
server is set to a different language.

Date format reloaded

Hi all.
How can i make sql 2000 server return dd/mm/yyyy instead of mm/dd/yyyy?
I know i can make formatting functions for that, but in this case i need to
set
the sql server locale correctly.
Thanks.
Sharon.SQL Server doesn't format datetime results, the client application does. So
you need to look for a
setting in the client app you are using. Some client application respect the
Regional Settings on
the machine where you run the client app. More info at:
http://www.karaszi.com/SQLServer/info_datetime.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Sharon" <nothing@.null.void> wrote in message news:eEp0uprDGHA.1288@.TK2MSFTNGP09.phx.gbl...

> Hi all.
> How can i make sql 2000 server return dd/mm/yyyy instead of mm/dd/yyyy?
> I know i can make formatting functions for that, but in this case i need t
o set
> the sql server locale correctly.
> Thanks.
> --
> Sharon.
>|||Thanks Tibor.
The problem was in the data source settings.
Sharon.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23CuxEurDGHA.2300@.TK2MSFTNGP15.phx.gbl...
> SQL Server doesn't format datetime results, the client application does.
> So you need to look for a setting in the client app you are using. Some
> client application respect the Regional Settings on the machine where you
> run the client app. More info at:
> http://www.karaszi.com/SQLServer/info_datetime.asp
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Sharon" <nothing@.null.void> wrote in message
> news:eEp0uprDGHA.1288@.TK2MSFTNGP09.phx.gbl...
>

Date Format Question

Hi all - I have a question regarding formating getdate(). Below is my query.

SELECT

cast(datepart(yyyy, getdate()) as char(4))

+'-'+ cast(datepart(mm,getdate()) as char(2))

+'-'+ cast(datepart(dd, getdate()) as char(2))

Result

2007-5 -30

The result I would like is:

2007-05-30

Can anyone help me with this?

Thanks in Advance.

You could use:

Code Snippet


SELECT convert( varchar(10), getdate(), 120 )


-
2007-05-30

Refer to Books Online, Topic: 'Cast and Convert' for the usage of the 'style' codes (the 120 above).

Date format question

I think this should be easy, but I'm stuck. I have a datetime field with this
format: mm/dd/yyyy. It looks exactly as that format when I opened the table
in EM. How come when I used Query Analyzer, the format became yyyy-mm-dd
hh:mm:ss?
I need to create a crosstab table from this table using the sp here:
http://www.sqlteam.com/article/dynamic-cross-tabs-pivot-tables with the date
field as the column heading. When I ran it, the column heading became Jan 1
2006 12:00AM, Feb 1 2006 12:00AM, etc. I want to see 01/01/2006, 02/01/2006,
etc instead. But I don't want to use convert because the date will be
converted to string and the columns won't be sorted by date anymore instead
it will be sorted like this: 01/01/2006, 01/01/2007, 02/01/2006, etc.
I hope this makes sense. Thanks in advance.
On Wed, 1 Aug 2007 13:46:03 -0700, lwidjaya wrote:

>I think this should be easy, but I'm stuck. I have a datetime field with this
>format: mm/dd/yyyy.
Hi lwidjaya,
Actually, you don't. You have a datetime column, period. Datetime values
are stored in an internal format that is not even comprehensible to
humans. The format you see depends on whatever formatting is applied by
the client.

> It looks exactly as that format when I opened the table
>in EM. How come when I used Query Analyzer, the format became yyyy-mm-dd
>hh:mm:ss?
Because QA uses other formatting than EM.

>I need to create a crosstab table from this table using the sp here:
>http://www.sqlteam.com/article/dynamic-cross-tabs-pivot-tables with the date
>field as the column heading. When I ran it, the column heading became Jan 1
>2006 12:00AM, Feb 1 2006 12:00AM, etc. I want to see 01/01/2006, 02/01/2006,
>etc instead. But I don't want to use convert because the date will be
>converted to string and the columns won't be sorted by date anymore instead
>it will be sorted like this: 01/01/2006, 01/01/2007, 02/01/2006, etc.
>I hope this makes sense. Thanks in advance.
You could of course use CONVERT with a format that won't mess up your
sorting (yyyy-mm-dd, for instance), but I think you'd better use a
completely different technique for the dynamic crosstab. The sqlteam
article uses at least one technique that is undocumented, unsupported,
and known to be unreliable in some cases, AND it uses a global temporary
table which means you'll get very interesting side effects if two users
execute it at the same time. There might be more issues, I couldn't
figure out what the hell this thing was doing after five minutes of
studying and I doubt you do understand everything - but the key to at
least somewhat reducing SQL injection risk when constructing dynamic SQL
is understanding every bit of the code.
Why not do something like this instead - still not completely safe from
all forms of SQL injection, but probably a lot better than what you're
using now.
USE pubs
go
DECLARE @.ord_date datetime,
@.sql nvarchar(4000);
SET @.sql = 'SELECT stor_id,'
DECLARE AllDates CURSOR FAST_FORWARD
FOR
SELECT DISTINCT ord_date
FROM dbo.sales
ORDER BY ord_date;
OPEN AllDates;
FETCH NEXT FROM AllDates INTO @.ord_date;
WHILE @.@.FETCH_STATUS = 0
BEGIN
SET @.sql = @.sql + 'SUM(CASE WHEN ord_date = '''
+ CONVERT(char(8), @.ord_date, 112)
+ ''' THEN qty ELSE 0 END) AS "'
+ CONVERT(char(10), @.ord_date, 101) + '",'
FETCH NEXT FROM AllDates INTO @.ord_date;
END;
CLOSE AllDates;
DEALLOCATE AllDates;
SET @.sql = STUFF(@.sql, LEN(@.sql), 1, ' FROM dbo.sales GROUP BY stor_id,
ord_date;');
PRINT (@.sql);
--EXEC (@.sql);
go
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
|||Hi Hugo,
Thanks a lot! That's what I need. It even replaces all 'Null' with zero.
Thanks again!
"Hugo Kornelis" wrote:

> On Wed, 1 Aug 2007 13:46:03 -0700, lwidjaya wrote:
>
> Hi lwidjaya,
> Actually, you don't. You have a datetime column, period. Datetime values
> are stored in an internal format that is not even comprehensible to
> humans. The format you see depends on whatever formatting is applied by
> the client.
>
> Because QA uses other formatting than EM.
>
> You could of course use CONVERT with a format that won't mess up your
> sorting (yyyy-mm-dd, for instance), but I think you'd better use a
> completely different technique for the dynamic crosstab. The sqlteam
> article uses at least one technique that is undocumented, unsupported,
> and known to be unreliable in some cases, AND it uses a global temporary
> table which means you'll get very interesting side effects if two users
> execute it at the same time. There might be more issues, I couldn't
> figure out what the hell this thing was doing after five minutes of
> studying and I doubt you do understand everything - but the key to at
> least somewhat reducing SQL injection risk when constructing dynamic SQL
> is understanding every bit of the code.
> Why not do something like this instead - still not completely safe from
> all forms of SQL injection, but probably a lot better than what you're
> using now.
> USE pubs
> go
> DECLARE @.ord_date datetime,
> @.sql nvarchar(4000);
> SET @.sql = 'SELECT stor_id,'
> DECLARE AllDates CURSOR FAST_FORWARD
> FOR
> SELECT DISTINCT ord_date
> FROM dbo.sales
> ORDER BY ord_date;
> OPEN AllDates;
> FETCH NEXT FROM AllDates INTO @.ord_date;
> WHILE @.@.FETCH_STATUS = 0
> BEGIN
> SET @.sql = @.sql + 'SUM(CASE WHEN ord_date = '''
> + CONVERT(char(8), @.ord_date, 112)
> + ''' THEN qty ELSE 0 END) AS "'
> + CONVERT(char(10), @.ord_date, 101) + '",'
> FETCH NEXT FROM AllDates INTO @.ord_date;
> END;
> CLOSE AllDates;
> DEALLOCATE AllDates;
> SET @.sql = STUFF(@.sql, LEN(@.sql), 1, ' FROM dbo.sales GROUP BY stor_id,
> ord_date;');
> PRINT (@.sql);
> --EXEC (@.sql);
> go
>
> --
> Hugo Kornelis, SQL Server MVP
> My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
>
|||On Fri, 3 Aug 2007 11:32:01 -0700, lwidjaya wrote:

>Hi Hugo,
>Thanks a lot! That's what I need. It even replaces all 'Null' with zero.
Hi lwidjaya,
Just in case you'd rather have the NULL, you only have to leave out the
"ELSE NULL" part of the dynamically built query.
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

Date format problem with SQL server

Hi.
I'm localized in Greece and the date format used is dd/mm/yyyy.

So I have is that I made a page with a callendar. The user picks a date and this date is stored to an SQL server. But here comes the problem. When I try to write to the server the above format ( dd/mm/yyyy ) is not accepted because SQL wants date in format ( mm/dd/yyyy). So if day is bigger than 12 I get error or if is less than 13 wrong date is stored in the SQL.

Any ideas?
Thanks in advanceWhen you are in code, be it SQL or C#/VB, always use the date data type NOT a string. When you display the contents of a date data type always use the appropriate culture. When you pass a value to SQL use an ado paramater of datetime. There should be no problem then. If, and I can't think why, you really want to pass a string to SQL with a date in it, then use a culture invariant such as YYYY-MM-DD|||Thanks for your quick reply.

No I'm not passing string to the SQL. Passing date data type. I read it as date, I use it as date in the calendar, and I try to write it as date in the SQL. but fail. :(|||That doesn't make any sense. Can you post how you are using it in SQL server?|||I read it as follow:
Dim cmd As New OleDbCommand("SELECT * from NEWS where id = " & Convert.ToInt64(myGlobalId), con1)

And I get no problem there. It reads correctly and displays correctly. all the fields.

And I write to the db as follow:

Dim cmd As New OleDbCommand("INSERT INTO NEWS (id, title, body, news_date) VALUES (" & newid & ",'" & titlebox.Text & "','" & bodybox.Text & "','" & mySdate & "')", con1)

mySdate has been declared as date and as datetime but no use. Also it has been test with and without quotes ('). Without quotes I get a new record but date is always 1/1/1900. With quotes I get an error when day is bigger than the month.

Thanks for your time...|||You are using a string! You must try to use params, for many many reasons, one of them is sorting out formating problems like you've got. Switch to using params and the problem will go away.
PS You really should worry about SQL Injection hacks so using params will get you around 99% of those too.|||What do you mean about security? Do you have a link so I read more about SQL Injection hacks?

I guess I'm sending a string as long as I use ['mySdate'] but I do not as long I send [mySdate]. When I send just [mySdate] I get a 1/1/1900 date in the SQL db. So the error should be elsewere. Also I found is that when a ODBC/System DNS is created there is an option "Use regional settings when outputing currency, numbers, dates and times" that can be checked/unchecked. But can't find somthing similar when creating my connection in visual studio...

Once more thanks for helping a newbie :)|||There are plenty of resources on SQL Injection, just type it into google and choose the one at the level most suited. Basically imagine someone has entered "'Delete from Stock" as a text string, it could actually run the SQL typed in, not what you want at all!

I didn't really follow what your statement, but trust me use paramaters. Look up SQLParameter and Commands. Your SQL should look more like...


"select * from table where column=?"

The question mark is a place holder for your first param. Look it up, honestly its much easier than I'm making it. But you really need to spend 20 mins and have a good read.|||You were right.
I used parameters and date problem solved. I have put the ? as you suggested and after I have the command:

"cmd.Parameters.Add("@.news_date", OleDbType.Date).Value = mydate"

Also seems that there is a protection for SQL injections... :)
The same for the other fields of course. :) Seems to work great now!

Thanks for your help.

Date Format MM/YYYY

Hi:
I need to format a date like this:
01/2004 -> 'MM/YYYY'
I know that I can do this...
SELECT CAST(datepart(mm,getdate()) AS VARCHAR) + '/' + CAST(datepart(yyyy,getdate()) AS VARCHAR)
but , Is there is another better solution?select right(convert(char(10), getdate(), 103), 7)|||Originally posted by joejcheng
select right(convert(char(10), getdate(), 103), 7)

Thanx a lot :D.
You save my life !!