AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQL Column Type (https://forums.alliedmods.net/showthread.php?t=153055)

EclipseCP 03-17-2011 21:52

SQL Column Type
 
hi , sorry for my bad english..

i have this code in menu:

PHP Code:

new day[11], hour[11]

format_time(daycharsmax(day), "%d/%m/%Y"g_day[id])
format_time(hourcharsmax(hour), "%H:%M:%S"g_day[id])

formatex(menucharsmax(menu), "Day: %d - Hour: %d"dayhour

as i have a record of accounts, the creation of the account, establishing the date (day and time)

PHP Code:

g_day[id] = get_systime()
formatex(consultcharsmax(consult), "UPDATE `%s` SET `character` = '%s', `date` = '%d' WHERE `acc` = '%s'"SQL_TABLEg_name[id], g_day[id], g_name2[id]) 



In short, I just want to know what type of SQL column is `date`, because it keeps the date and time, the truth would be grateful if I can help :) :3

katna 03-18-2011 05:36

Re: SQL Column Type
 
SQL COLUMNS:
PHP Code:

DATEdate without the time
DATETIME
date with time 

Example:
PHP Code:

CREATE TABLE `testing` (
  `
idINT(11AUTO_INCREMENT,
  `
namevarchar(64),
  `
dateDATETIME,
  
PRIMARY KEY (id)
); 

Datetime format is: yyyy-mm-dd hh-mm-ss ( 2011-18-03 12:33:01 )

EclipseCP 03-18-2011 14:51

Re: SQL Column Type
 
hello

I tested it, and leaves in 1895 or something like that O.O also wonder if you will not see the problem, so:

in the DB appears between LINES date (dd-mm-yy-), and I want to appear between / it so it would appear on the menu, any way?

Sylwester 03-18-2011 18:48

Re: SQL Column Type
 
When you get date from sql, you can replace - with / using replace_all.
Information about dates in sql: http://www.w3schools.com/sql/sql_dates.asp

EclipseCP 03-18-2011 20:43

Re: SQL Column Type
 
Quote:

Originally Posted by Sylwester (Post 1435553)
When you get date from sql, you can replace - with / using replace_all.
Information about dates in sql: http://www.w3schools.com/sql/sql_dates.asp

Hello, your answer helped me :)

I am a relative novice in SQL, is more or less but would query for a format time set a column? :?

Greetings

Sylwester 03-18-2011 21:49

Re: SQL Column Type
 
I'm not sure what do you mean, but if you want to assign value to a "DATETIME" type column, then you can use this:
PHP Code:

format(...,"INSERT INTO table_name (column_name) VALUES (DATE_SUB(NOW(), INTERVAL %d SECOND));"time_now-time_in_the_past

column_name is supposed to store some date in the past.
"SECOND" can be replaced with other type ( see this list ), but must match type used by time_now and time_in_the_past.

EclipseCP 03-19-2011 22:16

Re: SQL Column Type
 
Hello. :)

Shoot me syntax error. Using version 3.3.9.2 PHPMYADMIN remote connection.

What i do is convert a column format: %d %b %Y %T: %f

From here I took the format: http://www.w3schools.com/sql/func_date_format.asp

Greetings


All times are GMT -4. The time now is 14:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.