How To Increment Datetime Value In One Filed By Integer Value In Another Filed
Feb 12, 2008
hello everone
i have a table named "Concerned_Department" in which i ve a filed "Deadline"
of type DateTime.
i ve another table named "Cat_description" in wh i ve a filed "Max_Days"
of type int in wh i ve values 1,2 and 3.in "Cat_Description" table i ve "Cat_ID" as Primary key of type int.
all i want is if i select a row from "Cat_description" with "Max_Days"=1, i want to add this 1
to current date and and place it in the "deadline" field of "Concerned_Department" table.
like if today is 12/02/2008 then i want to place 13/02/2008 in "Deadline" filed of "Concerned_Deprtment"table
when a row with "Max_Days"=1 from "Cat_Description" is selected.
i am using SQL SERVER 2005 Exprees and C#(in source behind).
regards
Ahmed Bilal Jan
View 2 Replies
ADVERTISEMENT
Oct 20, 2004
I have a table with two primary key fileds. I will be running a process to populate the data into the table.For each process the first field is constant and second field is auto increment one.
My statements are insert into select ** from ** type one.
How do I auto increment second filed per run. Any delivered function available or any suggestion Pl.................
View 4 Replies
View Related
Oct 25, 2007
how is it possible to set a filed in a database to automatically add the current time to the filed at run time, is this possible; this filed has already been identified as 'DateTime' .
View 4 Replies
View Related
Apr 14, 2008
Hi
I'm having two datetime field in my table. One is Call date and another one is Calltime because of some calculations. So I want to save calldate like 4/14/2008 and calltime like 9:30 PM.
Kindly help me.
View 3 Replies
View Related
Apr 6, 2004
My database has chinese characters in.
Eventually I need to only get the first 50 bytes of the data field, but somehow, I use len('==data==',50), it would catch 50 chinese characters which make 100 bytes ...
can anyone help me?
Thank you very much no matter what the result is ;)
View 1 Replies
View Related
Apr 22, 2008
Hello,
i have a table with million record, an bigint filed like:
ID Name
-------------------------------------
1 Adam
4 Bob
5 Daivid
100 ...
Also i have unique index on filed ID, i want update this filed for any row to get row number and to be like:
ID Name
-------------------------------------
1 Adam
2 Bob
3 Daivid
4 ...
Can any one show me sample code ?
Kind Regards,
sasan.
View 6 Replies
View Related
Apr 18, 2007
i have two tables .Table 1 contains certain columns with values.Table 2 shud get those data from table1 into its column and display the calculated result. Any idea how do i go abt it,bcuz table2 shud contain a formula so as to calculate.
View 5 Replies
View Related
Feb 10, 2004
I don't know there is Password filed in SQL 2000 or not ?
If there is not , then How to hidden password in database.
pls help me !
View 1 Replies
View Related
Apr 20, 2008
HELLO FRIENDS
HOW YOU DOING ? HOPE FINE AND HAPPY
I BIG PROBLEM WHICH IS SMALL FOR YOU
HERE IS MY SQL STATMENT
SQLString = "select F01,F02,F03,F04,F05,F06,F07 from MovementTable where f011= KLM and f06 between 2 and 4"
HOW CAN HAVE COUNT IF F02=3 , F03=4 ,F04=5 THE TOTAL SHOULD BE =12
THANKS IN ADVANCE
View 12 Replies
View Related
Apr 18, 2008
Hi All,
For one of my reports, I need a expression smthing like this.
=IIf(Fields!Category.Value = "Decisioned" , THEN SHOW SUMMATION OF TOTAL APPLICATIONS WHERE Catergory = "Decisioned ," ")
Can anyone help me to write this expression.
Thanks
View 3 Replies
View Related
Aug 14, 2001
How can I make datatime filed a blank?
For example,
create table abc (day1 datetime, day2 datetime)
insert into abc values ('2001-08-09, '2001-08-13')
insert into abc values ('2001-08-10, '')
insert into abc values ('2001-08-11', '2001-08-15')
If i execute the above sql then I will have,
Day1 day2
==== ====
2001-08-09 2001-08-13
2001-08-10 1900-01-01
2001-08-11 2001-08-15
But I want to have the following result,
Day1 day2
==== ====
2001-08-09 2001-08-13
2001-08-10
2001-08-11 2001-08-15
How can I insert blank value in day2 column?
Thanks in advance
View 1 Replies
View Related
Jul 23, 2015
I want to CONCATENATE a field if the rows have the same Id. For example the data looks like
ID Name Identifier
1 ken English
1 Jack French
2 Jamie Spanish
3 Shirley German
The data should look like this if the IDs are same. I am concatenating the Identifier column with the name if the ids are same
ID Name Identifier
1 Ken English English
1 Jack French French
2 Jamie Spanish
3 Shirley German
View 8 Replies
View Related
Jun 18, 2007
Hello there
How are you? Hope fine and healthy
I have hug database which contain empty filed, I would like to fill the empty filed by inserting 0 in each empty filed using SQL command
May I have help please?
Thanks in advance
View 2 Replies
View Related
Aug 24, 2006
Hello I need to export my table fixed filed size by making numbers 15 characters right alignment and strings 20 characters left alignment.
View 1 Replies
View Related
Aug 24, 2006
Hello I need to export my table fixed filed size by making numbers 15 characters right alignment and strings 20 characters left alignment.
View 3 Replies
View Related
Nov 7, 2007
I have a database called ‘Objects’ which has many field. One of its fields is called ‘Image’ and has a data type image.
I want to add pictures to each one of my records offline, is this possible? i.e. by copying the address from my C drive such as C:Documents and SettingsfseyedarabiMy DocumentsMy Pictures
View 1 Replies
View Related
Feb 13, 2008
i ve a filed named "Email" of datatype .i ve created this field to insert email address in this field.but when i insert an email address like "bilal@yahoo.com" from a textbox wh is in an ASP.net webpage then in the filed i see this "System.Web.UI.WebControls.TextBox".
can u plz tell me how to fix this
Regards
Ahmed Bilal Jan
View 3 Replies
View Related
Jun 3, 2004
Hi,
I need to store large note in SQL Server field, what is substitute of Access's Memo filed in SQL Server?
Appreciated...
View 6 Replies
View Related
Jun 7, 2006
i am trying to insert an auot number field in my table which has got about million rows but sql 2005 is giving me na error "cant insert"
i need to index my table so that the query runs faster when i perform joins on two of such huge tables..
i tryid inserting the identity key the way it was mentioned in the forum but sql doesnt let me do that??
pls help
View 9 Replies
View Related
Apr 8, 2008
How can I validate the date that is coming across in a 8 byte character field via an expression? It will either be a valid date or 0. If it is zero I want to make it a null.
View 1 Replies
View Related
Oct 30, 2007
I have a database called 'objects' with one of its fields called 'Image' (data type is set to image) and a file in my desk top labelled as 'Pictures' (this is where all my pictures are keep). At run time i want to be able to select and add (upload) my preferred picture to the image filed of different records. Could you please advice me what i should do?
View 9 Replies
View Related
Jul 12, 2006
I have to run a dynamic sql that i save in the database as a TEXT data type(due to a large size of the sql.) from a .NET app. Now i have to run this sql from the stored proc that returns the results back to .net app. I am running this dynamic sql with sp_executesql like this..
EXEC sp_executesql @Statement,N'@param1 varchar(3),@param2 varchar(1)',@param1,@param2,GO
As i can't declare text,ntext etc variables in T-Sql(stored proc), so i am using this method in pulling the text type field "Statement".
DECLARE @Statement varbinary(16)SELECT @Statement = TEXTPTR(Statement)FROM table1 READTEXT table1.statement @Statement 0 16566
So far so good, the issue is how to convert @Statment varbinary to nText to get it passed in sp_executesql.
Note:- i can't use Exec to run the dynamic sql becuase i need to pass the params from the .net app and Exec proc doesn't take param from the stored proc from where it is called.
I would appreciate if any body respond to this.
View 2 Replies
View Related
Dec 29, 2005
Hi,
Following is the user defined function I want to get maximum value. It gives man an error "@strTableName must declare"
CREATE FUNCTION dbo.GetMaximum
(
@strFieldNamenvarchar(255),
@strTableName nvarchar(255)
)
RETURNS nvarchar(255)
AS
BEGIN
DECLARE @maxID int
SELECT @maxID=(SELECT IsNull(MAX(@strFieldName),0)+1 FROM @strTableName )
RETURN (@maxID)
END
View 5 Replies
View Related
Jan 11, 2008
Hi everyoneI am trying to create a DELETE Trigger. I have 2 tables. Table1 andTable2. Table 2 has all the same fields and records as Table1 + 1extra column "date_removed"I would like that when a record is deleted from Table 1, the triggerfinds that record in Table2 and updates the date_removed filed withcurrent time stamp.The primary key on both is combination of domain,admin_group and cn.CREATE TRIGGER [tr_updateTable2] ON [dbo].tbl_Table1FOR DELETEASUpdate Table2SET date_removed = getDate()I'm stuck here, how do I manipulate on Table2 only the records thatwere deleted on Table1, so to only update date_removed filed for themin Table2?I guess i need to compare domain, cn and admin_group, but I don't knowhow.Any help would be greatly appreciatedThanks! :-)
View 3 Replies
View Related
Jul 20, 2015
Working on a new database where the Date and Time are stored in a Date Time Field.
Then working on an OLDER database file within the same SQL Database contains these 2 items as integers:
transDate = "71615" (July 16, 2015)
transTime = "12345" (01:23:45 AM)
How do we convert both of them into a single SQL DateTime field such as "2015-07-16 01:23:45.000" so that it can be used in a join restricting to a date time in a different SQL File that properly has the DateTime in it?
This works well for converting the transDate Part in the select statement:
dbo.IntegerToDate(at.transDate) as transDate
* That returns: "2015-07-16 00:00:00.000"
* The resulting data must work directly in a Microsoft SQL Server Management Studio Query using either using the "on" statement or part of the "where" clause. In other words, NOT as a stored procedure!
Also must be able to be used as a date difference calculation when comparing the 2 files Within say + or - 5 seconds.
View 3 Replies
View Related
Sep 1, 2004
Hi,
Can anyone help me? I have created a table and with a primary key called "ID".
However, I want the "ID" be auto increment as well.
Here is my question, how can I do in the following format:
"PIC0001", "PIC0002", "PIC0003", ............ etc.
Anyone can help me?
Thanks.
View 15 Replies
View Related
Oct 5, 2007
Trying to write the most effective UDF to convert INT to Datetime.
We have a column from a table on AS400 that is a INT type. Some are 4, 5, 6 ,7 digits. I have the 4 digits right. I need to fix it for 5 and 6 digits.
ALTER FUNCTION IntegerToDatetime (@int INT)
RETURNS DATETIME
AS
BEGIN
DECLARE @IntegerToDatetime int
DECLARE @time DATETIME
SET @time = '2001-01-01'
SET @IntegerToDatetime =
CASE
WHEN LEN(@int) = 7
THEN '20' + CAST(SUBSTRING(CAST(@int AS CHAR(7)),2,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(7)),4,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(7)),6,2) AS int)
WHEN LEN(@int) = 6
THEN '19' + CAST(SUBSTRING(CAST(@int AS CHAR(6)),1,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(6)),3,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(6)),5,2) AS int)
WHEN LEN(@int) = 5
THEN '200' + CAST(SUBSTRING(CAST(@int AS CHAR(5)),1,1) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(5)),2,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(5)),4,2) AS int)
WHEN LEN(@int) = 4 THEN cast(@time AS INT)
END
RETURN (@IntegerToDatetime )
END
GO
INPUT
-------------------------------
990831
981019
RESULT
-------------------------------
1900-01-02 00:00:00.000
1900-05-27 00:00:00.000
http://www.sqlserverstudy.com
View 17 Replies
View Related
Apr 18, 2008
Hi
I use this to get all users from active directory.
SELECT *
FROM openquery(
adsi
,'SELECT name, AccountExpires FROM
''LDAP://company/OU=users,dc=company,dc=com''')
WHERE AccountExpires IS NOT NULL AND AccountExpires not in('0','0x7FFFFFFFFFFFFFFF','9223372036854775807','')
AccountExpires returns values like 128514708000000000 (This value represents the number of 100 nanosecond intervals since January 1, 1601 )
How do I convert this value to Datetime?
select getdate() returns a value like 2008-04-18 10:00:00.00 and that's how I'd like my AccountExpires
View 11 Replies
View Related
Apr 30, 2007
I was just told that it is better to convert all datetime values to integers for performance reasons. Is this generally true? I am working with time series data so datetime values hold important information.
View 10 Replies
View Related
Jul 20, 2005
Hi All,How do you convert int value to datetime datatype in sql servere.g 900mins to hh:mm:ssRegardsOla*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 3 Replies
View Related
May 2, 2006
Hello Everyone,
I need help with conversion type. I'm using Visual Basic 6.0 as my frontend and SQL Server 2000 as my backend. There has been existing data in the database. I would like to know how to convert an integer to datetime format. For example:
This is the actual value from the database.
1087912290
1087912327
I'd like to know how to convert it datetime format.
Any help would be greatly appreciated.
Thanks,
Dennis
View 14 Replies
View Related
Jul 20, 2005
Hi all,I have a problem converting datetime to integer (and than back todatetime).Depending whether the time is AM or PM, same date is converted to twodifferent integer representations, which holds as true on reversalback to datetime.AM Example:declare @DI integer; declare @DD datetimeset @DI = cast(cast('3/12/2003 11:34:02 AM' as datetime) as integer)set @DD = cast (@DI as datetime)print @DI; print @DDResult:37690Mar 12 2003 12:00AMPM Example:declare @DI integer; declare @DD datetimeset @DI = cast(cast('3/12/2003 11:34:02 PM' as datetime) as integer)set @DD = cast (@DI as datetime)print @DI; print @DDResult:37691Mar 13 2003 12:00AMNow, this is not a big problem if I knew that this is how it issupposed to work. Is this how SQL Server is supposed to work?
View 3 Replies
View Related
Aug 5, 2013
I have this datetime: '2002-12-20 11:59:59'
I want to convert this to date (yyyy-mm-dd) to integer
This works fine for: SELECT CONVERT(INT, GETDATE())
But it doesn't work here: SELECT CONVERT(INT, '2002-12-20 11:59:59')
I want to convert date to integer without passing through any varchar conversion/result.
View 6 Replies
View Related