GetDate() Month Issue

Aug 22, 2005

OK, simple question I am sure...

I have a very simple SQL command:
select convert(varchar, getdate(), 107);

I get the result:
Aug 22, 2005

How can I get it to say August 22,2005?

View 1 Replies


ADVERTISEMENT

How To Compare 2007-9-11 And Month(GetDate()) ?

Oct 30, 2007

I am going to compare thie value 2007-9-11 (this value was retrived from the column(TxnDate) in my DataBase, type is DateTime)
I write code  
select * from ZT_ModifyLog where Year(TXnDate) =  Year(GetDate()) AND (  ( Month(TXnDate) < Month(GetDate()) )  and Month(TXnDate) >= Month(GetDate())-1)
it will like
select * from ZT_ModifyLog where Year(2007-9-11 ) =  Year(GetDate()) AND (  ( Month(2007-9-11 ) < Month(GetDate()) )  and Month(2007-9-11 ) >= Month(GetDate())-1)
→  select * from ZT_ModifyLog where TxnDate(2007) = 2007 AND 10 < GetDate(10)  and 9 >= 9   so return TXnDate between 2007/9/1~ 2007/9/30
 but what if Month(GetDate())-13)?? when the -1 biger than 12... I guess the code will cause error ... but can't think out how to avoid and change my code
 
pleae help... thank you very much

View 1 Replies View Related

Select Month(getdate()) Format Plz

Apr 11, 2008

How can i return month in the format of 'April'.
 
When i am trying select month(getdate()) i am getting 4 but i am looking for text format - April.
 
Please correct format.
 
Thanks
Dk

View 2 Replies View Related

Transact SQL :: First And Last Day Of Previous Month From Getdate

Dec 10, 2010

How to get First day of previous month and last day of previous month(From getdate()) using SQL..?

View 13 Replies View Related

GETDATE.In A Combination Of Year And Month

Mar 7, 2008

I am trying to calculate the work experiance of an employee. I am using the function DATEDIFF for that.
For eg:




Code SnippetDATEDIFF(yy,JoiningDate,GETDATE())








But this will display the date difference in years, if I use mm, instead of yy then I will get the result in months.

But I want to dislay the result as a combination of year and month, like if an employee has 13 months of experiance then i want to get the result as 1.1 years. Is that possible using SQL?
Please help. All your helps will be appriciated.

View 12 Replies View Related

Select GetDate() Just The Month Or Year

Dec 21, 2006

I tried to find it on the Internet, but was unsuccessful. If someone can help me with a select statement that will return JUST the current month and year or day and month. I would really appreciate it.



Thanks

View 4 Replies View Related

Parameter Selection Of Month, Showing Selected Month And Sum Up To That Month In Another Row

Apr 5, 2008

Hello what I'd like to display the following in a matrix report:

Parameter selected: 3 (March), 2008 (Year)

Monthly TO Summed up
ArtNo March <=March
1210 20,500 50,900
1220 21,200 64,000
1230 15,400 40,300
... ... ...

So, in the rows I have the articles and in the column the selected month via parameter. In another column I need to sum up all monthly values up to the selected month, meaning in this example the sum of jan, feb and mar per article.

View 3 Replies View Related

Getdate() >= Startdate And Getdate() <= Enddate

Oct 4, 2000

Please i need an exmple of ur solution, thanks :)

I'm using some files to show certain pages on certain date for an example

File name : aa.doc
start date: 10/02/00
end date : 10/03/00

But it expires on 10/02/00, here is the strored procedure:

Before the date comes, it expires the page
Here is my stored procedure:

"
SELECT startdate, enddate,archivedate
and (startdate is null or (getdate() >= startdate and getdate() <= enddate))
and (archivedate is null or (getdate() <= archivedate))
group by startdate, enddate order by startdate desc "

Thankx a lot

View 1 Replies View Related

T-SQL (SS2K8) :: Get Last Record In A Month When No Guarantee Month Exists Of Unique Dates?

Apr 22, 2015

following table global_usage

ID varchar (contains alphanumeric values,not unique)
Territory (combined with ID unique)
Total_Used int can be null
Date_ date (date of the import of the data)
ID Territory Total_Used Date_
ACASC CAL071287 2014-06-01
ACASC CAL071287 2014-08-01
ACASC CAL071288 2014-09-01

[Code] .....

Now the problem,per month I need the most recent value so I'm expecting

ACASC CAL071287 2014-06-01
ACASC CAL071287 2014-08-01
ACASC CAL071288 2014-09-01
ACASC CAL071288 2014-11-01
ACASC CAL071190 2014-12-14
ACASC CAL071286 2015-01-22
ACASC CAL071165 2015-02-01
ACASC CAL071164 2015-03-01

I've tried a few thing like group,having even row_number() but I keep getting wrong results

View 6 Replies View Related

Transact SQL :: Show (0) Amount For A Month If No Data Exists In The Table For That Month?

Nov 9, 2015

I have two tables Costtable (Id,ResourceId, Amount,Date) and ResourceTable (ResourceId,Name) which shows output as below.

I want to show 0 amount for rest of the name in case of September. For e.g. if rest of the Resources does not appear in cost table they should appear 0 in amount

My Desired output

My current query

SELECT
RG.Id AS Id,
RG.Name AS Name,
ISNULL(SUM(AC.Amount), 0) AS Amount,
RIGHT(CONVERT(varchar(10), AC.[Date], 105), 7) AS [YearMonth]

[Code] ....

View 6 Replies View Related

T-SQL (SS2K8) :: Convert Number Of Month In Integer Into How Many Year And Month

Sep 10, 2014

This is my table and data

CVID | WorkExperience
--------------------------------
2838736
68181101
96568122
1135484

I need to convert into this result

CVID | WorkExperience
--------------------------------
283873 years
681818 years 5 months
9656812 years 2 months
1135484 months

View 5 Replies View Related

Transact SQL :: Displaying Sales Data In A Month By Month Grid

Aug 11, 2015

Most of the data is in one table. 

Company 1-Jan 1-Feb 1-Mar 1-Apr
RSP RSP RSP RSP
NON-RELO $295 1 $0 0 $1,400 7 $0 0 $1,195 4 $0 0 $4,700 8 $0 0
AMERICAN ESCROW & CL//AECC $2,650 4 $0 0 $3,720 8 $0 0 $2,339 4 $0 0 $2,460 2 $0 0
American Internation//AIRCO $9,131 30 $2,340 9 $10,927 35 $2,340 9 $9,142 31 $2,600 10 $18,406 54 $3,900 15
American Internation//AIR $20,611 63 $1,820 8 $23,892 75 $1,040 4 $35,038 111 $3,120 12 $3,778 16 $1,560 6
American Internation//Ab $64,248 206 $6,240 24 $59,800 187 $5,200 20 $87,115 264

I did something similar doing just record counts but this is far more complicated. I'm at a loss that this is even possible.

 SUM(CASE datepart(month, tbFile.openedDate) WHEN 1 THEN 1 ELSE 0 END) AS 'January', 

View 2 Replies View Related

Select Convert(varchar(16), Getdate(), 101)+LEFT(REPLACE(convert(varchar, Getdate(), 108), ':', ''),4)

Sep 26, 2007



select convert(varchar(16), getdate(), 101)+LEFT(REPLACE(convert(varchar, getdate(), 108), ':', ''),4)

From above query I get

mmddyyyyhhmm

but it' s yyyy and hour can not be separated

04/12/200702:05

How can I separated the year and hour ?

Thanks
Daniel

View 2 Replies View Related

Get Last Day Of Month For Agiven Month And Year

Aug 2, 2002

Does anyone know how I can get last day of month
if I pass a function a given month and and given year.
@Month = 2
@Year = 2004
The result I would need is 29 because there are 29 in
the month of February in the 2004.
Any help on this is greatly appreciated.
Kellie

View 1 Replies View Related

SQL 2012 :: Use Date Trunc Or Date Function To Select Date Range For Month On Month View

Jul 29, 2015

My goal is to select values from the same date range for a month on month view to compare values month over month. I've tried using the date trunc function but I'm not sure what the best way to attack this is. My thoughts are I need to somehow select first day of every month + interval 'x days' (but I don't know the syntax).In other words, I want to see

Select
Jan 1- 23rd
feb 1-23rd
march 1-23rd
april 1-23rd
,value
from
table

View 9 Replies View Related

Month-to-month Function

Sep 10, 2007

Hi I trying to find a way to determine the number of working days per month starting from the current date to the last day of the current month.And within the same store procedure determine the number of working days as normal (each month is independent from the next). For example: The store procedure is executed

September:
@CurrentDate = 9/10/2007
@EndDate = last working day 9/30/2007

Total# of working days = 15

October:
@CurrentDate = 10/1/2007
@EndDate = last working day 10/31/2007

Total# of working days = 23

November:
@CurrentDate = 11/1/2007
@EndDate = last working day 11/30/2007

Total# of working days = 22
etc.
Any ideas of how i can approch this?

Thanks in advance.

View 3 Replies View Related

Grouping My Month/year Desending By Month/year

Dec 11, 2006

i have some classes that I want to group by month/year (note:i dont need the day of the month)
how do i wirte my sql so it only gives me the dictinct groups month/year  of the classes I have so that it comes out like so..
11/2006
12/2006
1/2007
3/2007
i try with my sql below but i cant get the groups th come out in order. i dont think it sees it as a date value.
dbo.classgiven.classdate date of the class.thank you all 
SELECT DISTINCT { fn MONTH(dbo.classgiven.classdate) } " + "/"  + "{ fn YEAR(dbo.classgiven.classdate) } AS monthyear,{ fn MONTH(dbo.classgiven.classdate) } AS monthcode   FROM  dbo.classT INNER JOIN dbo.classgiven ON dbo.classT.classcode = dbo.classgiven.classcode WHERE (dbo.classT.discount = '-1') AND  (dbo.classT.coned IS NOT NULL)", conNorthwind )

View 9 Replies View Related

GetDate()

May 13, 2008

When I use the getDate() function I get something like
2005-03-09 15:13:45.017
 but I don't want the time, just 2005-03-09
how do you strip out the time from the result?
Thanks

View 2 Replies View Related

Getdate

May 28, 2008

How can i getdate in C# code, like we do in SQL Server ?
 Thanks.

View 1 Replies View Related

Getdate In Sql 7.0 And Sql 6.5

Apr 27, 2001

However, when I run select getdate() in Sql 6.5 I get the following
Apr 27 2001 11:59AM

Both queries are run from the QueryIsql window.

How can I get the sql 7 version of getdate to be exactly the same as the
sql 6.5 version from the query window without resorting to usign the
convert function?

According to Sql 7 books online, getdate
"Returns the current system date and time in the Microsoft® SQL Server™ standard internal format for datetime values"

View 1 Replies View Related

Getdate() ??????

Oct 3, 2000

I'm facing some strange problem here:
-----------------------------------------

I'm using some files to show certain pages on certain date for an example

File name : aa.doc
start date: 10/02/00
end date : 10/03/00

But it expires on 10/02/00, here is the strored procedure:

Before the date comes, it expires the page
Here is my stored procedure:

"
SELECT startdate, enddate,archivedate
and (startdate is null or (getdate() >= startdate and getdate() <= enddate))
and (archivedate is null or (getdate() <= archivedate))
group by startdate, enddate order by startdate desc "

Thankx a lot

View 2 Replies View Related

GetDate()

Sep 20, 2000

i am also trying to write a query that
retrieve information on yesterdays new registered
member. So far as i am concern with sqlserver you use
the getdate()-1 to retrieve this information. But the
problem i get when i try to use the getdate()-1 is
that i tend to get todays and yesterdays registered
users. Is there anywhere that i would be able to
retrieve information on just yesterdays new registered
members and also only todays new register members.

View 1 Replies View Related

GetDate

Sep 28, 2000

The following WHERE clause does not generate a datetime from my GETDATEs. Can anyone help me out on the syntax?

WHERE (FROMTIME = GETDATE() AND ToTime = GETDATE())

Thanks much.
TM

View 7 Replies View Related

Using Getdate() In An UDF

Aug 7, 2003

Is it right, that getdate() cannot be used in an user defined function. if so, then how do i get hte current date and time in my function?

View 2 Replies View Related

Getdate

May 19, 2005

Hi

I know this is going to sound really daft, but what is the easiest way of getting today's date without the time? Getdate() on it's own doesn't work because it always brings out the time. I know I'm missing something really basic but I can't figure it out.

Please help.

Thanks

View 3 Replies View Related

Getdate()

Aug 17, 2005

How to get the first and last day of the previous month using function getDate()?

View 2 Replies View Related

GetDate()

Oct 20, 2004

G'day,
I want to display the current time minus 5 minutes. say
2004-03-29 11:43:49.123 to be 2004-03-29 11:38:49.123.

Is there any Equivalent to the DB2's CURRENT TIMESTAMP - 5 MINUTES which will display the current day say 2004-03-29 11:43:49.123 as
2004-03-29 11:38:49.123


cheers
Melb

View 2 Replies View Related

Getdate()

May 19, 2006

I'm using getdate() - 74 and getting something like

2006-03-06 11:26:02.870

Is there a simple way to get

2006-03-06 00:00:00.000

instead?

Or just get the date and not the time part. I'm using this date with a between function and the time component is throwing it off.

I'm using

cast(convert(char, getdate(),112) as datetime) - 74

and it works...but there must be an easier way...

View 6 Replies View Related

Getdate()

Feb 10, 2007

Hi,
when I used getdate() fuction, its giving the correct time in this format 10/02/2007 01:04:31 PM. But I need the time in 24 hour format. Means it should be like 10/02/2007 13:04:31.

How to get it. Please help me!!

shaji

View 5 Replies View Related

Getdate()

May 21, 2007

select
H.IsoDate,
HI.Country,
HI.Center,
H.ExchangeCode,
HC.Holiday,
H.HolidayCode
from
Holidays H
join
HolidayInfo HI
on
HI.Code = H.ExchangeCode
join
HolidayCodes HC
on
H.HolidayCode = HC.Code
where
H.isodate = getdate()

This is a script but the getdate part is not working can somebody point me in the right direction where i might be going wrong.

The date format in H.isodate is like this:

2005-06-24 00:00:00.000

cheers in advance

View 2 Replies View Related

GetDate()

Dec 27, 2007

Hello,

I'm new to SQL server and I'm trying to insert the system time into a table.

I'm using following insert statement. But I get an error 'incorrect syntax near the keyword select'

INSERT INTO today(datum) VALUES(SELECT getdate() FROM today)

The datatype of datum is Datetime

Can someone please tell me what I'm doing wrong

Thanks

View 1 Replies View Related

To Getdate() Or Not To Getdate()

Mar 13, 2008

I am setting up a table and I want to capture the creation date of each record when it comes in. Obviously the easy way to do this is set the dfault value of this field to getdate(), but I am wondering if there is a benefit to using an insert trigger instead?

I will also be adding a seperate updatedOn field and plan to use an update trigger to populate it. If there is a better way to do either of these please let me know.

View 3 Replies View Related

Getdate

Mar 13, 2008

Folks:

I use,

PRINT CONVERT(VARCHAR, GETDATE())

To write the current date to the console (for debugging purposes). Only problem is it only shows hours and minutes (not seconds). Can anyone suggest an equivalent that shows seconds as well?

View 1 Replies View Related







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