Coder Social home page Coder Social logo

arman228228 / get-week-day-with-mysql-for-sa-mp Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 23 KB

Find out the day of the week using MySQL for SA-MP

grand-theft-auto gta gta-sa gtasa gtasanandreas pawn pawno sa-mp sa-mp-development sa-mp-server server-tools

get-week-day-with-mysql-for-sa-mp's Introduction

Get week day with MySQL

Find out the day of the week using MySQL

Function (MySQL R41 Version):

get_week_day()
{
	new day_id,
    	       Cache: mysql_result,
	       year, month, day,
	       fmt_date[35];
		
	getdate(year, month, day);
	
 	/*
  	mysql_connect_id - instead, use your database connection variable
 	*/
  
	format(fmt_date, sizeof(fmt_date), "SELECT WEEKDAY(\"%02d-%02d-%d\")", year, month, day);
	
	mysql_result = mysql_query(mysql_connect_id, fmt_date);
	
	if(cache_num_rows())
		cache_get_value_index_int(0, 0, day_id);

	cache_delete(mysql_result);
    
  	return day_id;
}

Function (MySQL R39 Version):

get_week_day()
{
	new day_id,
    	Cache: mysql_result,
		year, month, day,
		fmt_date[35];
		
	getdate(year, month, day);
	
 	/*
  	mysql_connect_id - instead, use your database connection variable
 	*/
  
	format(fmt_date, sizeof(fmt_date), "SELECT WEEKDAY(\"%02d-%02d-%d\")", year, month, day);
	
	mysql_result = mysql_query(mysql_connect_id, fmt_date);
	
	if(cache_num_rows())
    	       day_id = cache_get_row_int(0, 0, mysql_connect_id);

	cache_delete(mysql_result);
    
  	return day_id;
}

How to use:

    
static const days_name[7][12] = {
	"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"
};

printf("current week day: %s", days_name[ get_week_day() ]);

get-week-day-with-mysql-for-sa-mp's People

Contributors

arman228228 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.